+ 2
[Answered] Am i right?
The code: https://code.sololearn.com/WU9OzCXvq0Cf/?ref=app I wonder if it work like this: First refering to the current object by "this." keyword, then assigning function's name parameter to object's name parameter. So "p.changeName("John")" refers to "p" variable (object), calls "changeName" function which changes object's "name" parameter (which currently is "David") to the function's "name" parameter (which is "John"(defined in: "p.changeName( /* here */ "John")") ). Please tell if im wrong.
3 Answers
+ 1
The logic is right.
Only two terminology to note:
1. p is an "instance", because you used the "new" keyword. So if you
var p2 = new Person()
You will create another instance.
2. p.name is "property" of the instance p. Each property is a key-value pairs.
+ 1
yes
0
Thank you for answering to me.