Why is the output 1?

topic description

sources of topics and their own ideas

related codes

/ / Please paste the code text below (do not replace the code with pictures)

var obj = {a:1};
function fun (obj){
    obj = {a:2}
}
fun(obj)
console.log(obj)

what result do you expect? What is the error message actually seen?

Why is the output {avl 1}? Shouldn"t the obj in the
function be promoted as a global variable without a var declaration?

Oct.15,2021

var obj = {a:1};
function fun (obj){
    console.log(arguments);
    obj = {a:2}
}
fun(obj)
console.log(obj)

try this and you'll see


  

the expression obj is a formal parameter, which is valid only within the function and does not affect the obj outside the function

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e5927c-454ea.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e5927c-454ea.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?