📌  相关文章
📜  javascript 按值传递 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:48.303000             🧑  作者: Mango

代码示例1
function func(obj) {
  obj = JSON.parse(JSON.stringify(obj)); //If too slow, replace with other method of deep cloning
  obj.a += 10;
  return obj.a;
}

var myObj = {a: 5};
func(myObj); //Returns 15 and myObj.a is still 5