一、
var num = 100; console.log('函数调用前num的值',num);//100 function changValue(num){ num = 666; console.log('函数调用中num的值',num);//666 } changValue(num); console.log('函数调用后num的值',num);//100 666
二、
var boyFriends = ['张艺兴', '胡歌', '宋小宝'];
console.log('函数调用前',boyFriends);// ['张艺兴', '胡歌', '宋小宝'];
function changValue(value){
value[0] = '孙楠';
console.log('函数调用中',value);//["孙楠", "胡歌", "宋小宝"]
}
changValue(boyFriends);
console.log('函数调用后',boyFriends);//['张艺兴', '胡歌', '宋小宝'];
三、
var boyFriends = ['张艺兴', '胡歌', '宋小宝'];
console.log('函数调用前',boyFriends);
function changValue(value){
value = ['杨幂','金星','冰冰'];
console.log('函数调用中',value);
}
changValue(boyFriends);
console.log('函数调用后',boyFriends);