Regular objects can be cloned using this method:
a = {x:9}; //sample b = Object.assign(Object.create(a),a); console.log(a); console.log(b); However, the variables of Date type don't seem to work with Object.assign and Object.create:
a = new Date(); b = Object.assign(Object.create(a),a); console.log(a); console.log(b); /* Results of printing a, b are not the same: a: Thu Oct 20 2016 11:17:29 GMT+0700 (SE Asia Standard Time) b: Date {} */ I know I can create a clone of Date object another way using
b = new Date(a) But why are Object.assign and Object.create not working on Date type?