如何在var中存储对象值?

时间:2017-01-11 01:54:56

标签: javascript arrays variables object store

我尝试理解JavaScript中的基本概念。

如果有人做了一些澄清。

如果我有这个。

//example: i have storing a default permanente array value with a constructor in: $gameSystem.huds.hudsSlot.default = [10,5]; 
console.log($gameSystem.huds.hudsSlot.default); // return me [10,5]; is nice

//now in a context, i need to store this value in temps var to do some stuff
var test = $gameSystem.huds.hudsSlot.default;
console.log(test): // return me [10,5]; is nice

// but after, if i do 
test[0]++;
// or
test[0]+=1;

console.log(test[0]); // return me 11 ( is ok ) !
//But why 
console.log($gameSystem.huds.hudsSlot.default) // return me 11 ??????
// why test[0]++; or test[0]+=1; increase my objets $gameSystem.huds.hudsSlot.default ???
// why increase my var test[0] increase $gameSystem.huds.hudsSlot.default[0] in same time ?

非常感谢帮助我

0 个答案:

没有答案