原理:https://blog.csdn.net/mChales_Liu/article/details/103112986
基本类型值:
var a = 1;
function fn (a) {
a=2;
}
fn(a);
a;// 1
引用类型值:
var arr = [1];
function fn (arr) {
arr[0]=2;
}
fn(arr);
arr;// [2]
原理:https://blog.csdn.net/mChales_Liu/article/details/103112986
基本类型值:
var a = 1;
function fn (a) {
a=2;
}
fn(a);
a;// 1
引用类型值:
var arr = [1];
function fn (arr) {
arr[0]=2;
}
fn(arr);
arr;// [2]