What does timestamp = + new Date () mean?

How is

timestamp = + new Date () calculated and assigned?

Mar.13,2022

+ variable
implicitly calls the variable's valueOf method and converts it to numeric type

var obj = {
  toString(){
    console.log('toString');
    return '13'
  },
  valueOf(){
    console.log('valueOf');
    return []
  }
}

console.log(+obj)// valueOf toString 13

first call valueOf if the value returned by valueOf is not the original value, it will continue to call toString and convert the string 13 to number 13

.


is equivalent to Date.now () timestamp assignment


  1. The result of new Date () is a Date object
  2. + is a unary operator that changes the following variable to a type of Number , which is equal to Number (new Date ()) .
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3e3a1-2c3e0.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3e3a1-2c3e0.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?