First look at question 1
var obj = {name: ' A '}function Bar (obj) { console.log (obj.name); = {Name: "B"}; Console.log (obj.name)}console.log (bar (obj)) console.log (obj.name)
In the chrome console, do the following to find out what to print
a b a
Question 2, a little bit of a change
var obj = {name: ' A '}function Bar (obj) { console.log (obj.name); = "B"; Console.log (obj.name)}console.log (bar (obj)) console.log (obj.name)
In the chrome console, do the following to find out what to print
Abb
Question 3, change it a little bit.
var obj = {name: ' A '}function Bar (obj) { console.log (obj.name); var obj = {name: "B"}; Console.log (obj.name)}console.log (bar (obj)) console.log (obj.name)
In the chrome console, do the following to find out what to print
Aba
Question 4, continue to change
var obj = "name"function Bar (obj) { console.log (obj); var obj = "age"; Console.log (obj)}console.log ("Bar (obj)") console.log (obj )
Find this to print
Nameagename
Question 5, continue to change
var obj = "name"function Bar () { console.log (obj); var obj = "age"; Console.log (obj)}console.log ("Bar (obj)") console.log (obj )
Discover Print in sequence
Undefinedagename
Question 6, or continue to change
var obj = "name"function Bar () { console.log (obj); = "Age"; Console.log (obj)}console.log ("Bar (obj)") console.log (obj )
Look what you're going to print this time.
Nameageage
If you're right, you understand reference passing and value passing, understanding local variables and global variables, and if you're wrong, think about it.
A JS question about reference passing and value passing