代码
var datetime = new Date();
for(var key in datetime){
console.log(datetime[key]);
}
var person = {'name':'savo','age':18};
for(var key in person){
console.log(person[key]);
}
以上代码输出:
savo
18
疑问
person
这个自定义对象可以遍历出来属性datetime
这个对象就不行,是不是它不让枚举啊?
我想看这个datetime
对象里面都有啥该咋看?
其實只是想看看的話,
console.dir(new Date());
如果沒有 console 的話,
http://.com/a/1190000002689750
这个是类似的问题
javascript
var arrObj = Object.getOwnPropertyNames(Date.prototype); for( var funcKey in arrObj ) { console.log(arrObj[funcKey]); }