递归与非递归遍历
var properties = []; function getProps(obj) { if (typeof target == 'object') { for (var key in obj) { if (obj.hasOwnProperty(key)) { properties.push(key); eachProp(obj[key]); } } } } function getProps2(obj) { var props = []; var queue = [obj]; var target; while(target = queue.shift()) { if (target && target.constructor === Object) { for (var key in target) { props.push(key); queue.push(target[key]); } } } return props; }