var object = {}; for(var i=0; i<5; i++){ object['attr'+i] = i; } 转载于:https://www.cnblogs.com/zhucj/p/9644599.html