If I want the result of the function f2 to be the same as f1, can I solve this problem by adding a statement to f2?If such a solution is possible, what is an example of a solution?
let date;f1();f2();
function f1() {date=newDate(1970,0,1,0,0,0); console.log(date);}
// Thu Jan 01 1970 00:00 GMT+0900 (Japan Standard Time)
function f2(){
constarray = [1970,0,1,0,0,0,0];
date = new Date(array);
console.log(date);
}
// Invalid Date
For example, you can solve the problem by applying the spread syntax (comment suggestion).
date=newDate(...array);
© 2024 OneMinuteCode. All rights reserved.