When calling new Date()
, you will get a date object. When calling console.log(new Date())
, the toString
-method of the date object will implicitly get called (not 100% true, but you get the idea). How the console
-object works, is implemented by your browser/enironment. My guess is showing the date as a string is a convenience they've build in.
Like others have mentioned in the comments, try console.log(typeof new Date())
/console.dir(new Date())
or to call any of the methods documented. You'll see it is most definitely an object.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…