In Javascript why do Date objects have both valueOf and getTime methods if they do the same?

后端 未结 3 2123
南旧
南旧 2020-12-25 10:26

MDN says that valueOf and getTime are functionally equivalent. Why have two functions that do the very same thing?

3条回答
  •  北海茫月
    2020-12-25 10:58

    valueOf is a method of all objects. Objects are free to override this to be what they want.

提交回复
热议问题