function getString(s){
s='新字符串';
}
var s='传入的字符串';
console.log(s);// s='传入的字符串';
getString(s);
console.log(s);//s='传入的字符串';
字符串没有改变,换成数字也是这样.
但如果
function getString(s){
s.str='新字符串';
}
var s={'str':'传入的对象字符串'};
console.log(s.str);//传入的对象字符串
getString(s)
console.log(s.str);//‘新字符串'
此时参数改变了。