Listing the available properties / functions for Date in JavaScript

后端 未结 2 1357
失恋的感觉
失恋的感觉 2021-01-29 05:07

I am trying to list the properties / functions for Date in JavaScript using the below code:

var mydate=new Date();
for(var i in mydate){
   console.log(i);
}
         


        
2条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-29 05:53

    Many built-in objects have their methods set to not be enumerable, and therefore won't show up in a for..in loop.

    You should instead look up some documentation, and then you can test if your browser supports certain things like:

    if( 'now' in Date)
    

提交回复
热议问题