首页 > 我想看date对象里面的属性,怎么看?

我想看date对象里面的属性,怎么看?

代码

        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


这个是类似的问题

javascriptvar arrObj = Object.getOwnPropertyNames(Date.prototype);
for( var funcKey in arrObj ) {
   console.log(arrObj[funcKey]);
}
【热门文章】
【热门文章】