如何将一张地图复制到另一张地图?
2022-08-30 04:41:54
如何在JavaScript中克隆/复制?Map
我知道如何克隆阵列,但是如何克隆/复制?Map
var myArray = new Array(1, 2, 3);
var copy = myArray.slice();
// now I can change myArray[0] = 5; & it wont affect copy array
// Can I just do the same for map?
var myMap = new ?? // in javascript is it called a map?
var myMap = {"1": 1, "2", 2};
var copy = myMap.slice();