xugy0926 / getting-started-with-javascript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

6.小小恶作剧中函数两种不同变量类型的不同引用方式

fdy696 opened this issue · comments

<script> function cooking(foodList1){ foodList1[2] = "rich"; // console.log(foodList1); }
var foodList = ["fish", "list"];
cooking(foodList);
console.log(foodList);


	
</script>
` 执行结果:(3) ["fish", "list", "rich"] 此处foodlist为引用类型,两者相互影响

foodList为实参