[Answered] Am i right? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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.

12th Dec 2021, 10:12 PM
Hecker
Hecker - avatar
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.
13th Dec 2021, 6:03 AM
Gordon
Gordon - avatar
+ 1
yes
13th Dec 2021, 5:33 AM
ACE
ACE - avatar
0
Thank you for answering to me.
14th Dec 2021, 2:44 PM
Hecker
Hecker - avatar