反射属性
findProperty: function (object, path) {
var props = path.split(".");
for (var i = 0; i < props.length; i++) {
var p = props[i];
if (object && object.hasOwnProperty(p)) {
object = object[p];
} else {
return undefined;
}
}
return object;
},
遍历属性
let enumerableKeys = [];
for (let key in natureColors) {
enumerableKeys.push(key);
}
enumerableKeys; // => ['colorC', 'colorD', 'colorA', 'colorB']