티스토리 뷰

공부

[JS] date deep copy

승가비 2020. 10. 28. 01:09
728x90
var date = new Date();
var copiedDate = new Date(date.getTime());

var date = new Date();
var copiedDate = new Date(date);

https://stackoverflow.com/questions/1090815/how-to-clone-a-date-object

 

How to clone a Date object?

Assigning a Date variable to another one will copy the reference to the same instance. This means that changing one will change the other. How can I actually clone or copy a Date instance?

stackoverflow.com

 

728x90

'공부' 카테고리의 다른 글

[JS] screenshot of div  (0) 2020.10.28
[Java] random shuffle list  (0) 2020.10.28
[Java] distinct by property  (0) 2020.10.28
[JS] get yesterday  (0) 2020.10.28
[Java] getHour()  (0) 2020.10.28
댓글