首先我对标题表示歉意。
我有一个尚未实例化的原型(prototype):
noZoom
和 zoom
对象将在实例化时填充对象。
我想插入propertiesToIlluminate array
noZoom
内的所有对象我的 Persona
中所有属性的对象构造函数。
function Persona() {
this.headArea = {
noZoom: {},
zoom: {}
}
this.torsoArea = {
noZoom: {},
zoom: {}
}
this.arm = {
noZoom: {},
zoom: {}
}
this.leg = {
noZoom: {},
zoom: {}
}
this.pelvis = {
noZoom: {},
zoom: {}
}
this.abdomen = {
noZoom: {},
zoom: {}
}
this.illuminate = function() {
var propertiesToIlluminate = [],
prop, illuminateInternal, i = 0,
delay = 100,
intervalId;
for (prop in //what to put here//) {
propertiesToIlluminate.push(prop);
}
}
}
最佳答案
试试这个:
for (prop in this) {
if (this[prop].noZoom) {
for (key in this[prop].noZoom) {
if (this[prop].noZoom.hasOwnProperty(key)) {
propertiesToIlluminate.push(this[prop].noZoom[key]);
}
}
}
}
关于javascript - 将属性对象的选定对象从原型(prototype)插入数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24587541/