【Udemy排名第一的JavaScript課程】2023最新完整JavaScri

課程重點(diǎn):
1.在JS函數(shù)內(nèi)部修改函數(shù)參數(shù),基本類型和引用類型的區(qū)別。
const num= 6;
const person = {
name:"小紅",
age:18
}
function change(value,obj){
value = 5;
obj.name = "小明";
}
change(num,person);
console.log(num); // 5
console.log(person); // name = "小明"
2.JS 只有按值傳遞,沒有按引用傳遞。
But it's confusing ,because as we just learned for objects ,we do in fact pass in a reference. So the memory address of the object. However ,that reference itself is still a value. It's simply a value that contains a memory address. So basically we pass a reference to the function,but we do not pass by reference, and this is an important distinction.
3.學(xué)過c語言的胖友可能更懂按引用傳遞,咱還不是很懂。
標(biāo)簽: