javascript - How to copy moment
淡淡烟草味
淡淡烟草味 2017-05-16 13:42:33
0
2
712
const a = moment(); 
console.log('a', a); // 4月24日
const b = a.add(1, 'days');
console.log('a', a);// 4月25日
console.log('b', b);// 4月25日

If you copy a, while b is April 25, a remains unchanged.

淡淡烟草味
淡淡烟草味

reply all(2)
phpcn_u1582

In fact, moment itself supports the function you mentioned. You only need to put the variable you want to copy into moment and generate another one. The two will not affect each other.

const a = moment(); 
console.log('a', a); // 4月24日
const b = moment(a).add(1, 'days');   //moment一下,完成对a的复制
console.log('a', a);// 4月24日
console.log('b', b);// 4月25日
迷茫
const a_clone = a.clone();
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template