stefanbund / 311

Interactive Web Development
33 stars 46 forks source link

Question on js-object2.html #16

Closed PatrickMinett closed 7 years ago

PatrickMinett commented 7 years ago

2 questions:

I noticed that in the example the object we created has a internal function called,

this.changeName = function(name) case 2

I was under the impression that a function had to have the following syntax function nameOfyourFunction() case 1

so I am assuming, that we have three options with uniquely identifying a function in js, we can name it, like in case 1 or we can give it a parameter list which then uniquely identifies it like in case 2 or we do both. Is this correct?

Second question in the example I noticed that a return statement was not needed. Why is that?

thanks for the help.

stefanbund commented 7 years ago

Great observation. There are a number of options the programmer has to incorporate functions within the object. You did take note of a strategy of initializing a class attribute with the function, this works like a function but is called like an attribute… It's pretty professional I must say

From Stefan Bund

On Jan 15, 2017, at 11:36 AM, PatrickMinett notifications@github.com wrote:

2 questions:

I noticed that in the example the object we created has a internal function called,

this.changeName = function(name) case 2

I was under the impression that a function had to have the following syntax function nameOfyourFunction() case 1

so I am assuming, that we have three options with uniquely identifying a function in js, we can name it, like in case 1 or we can give it a parameter list which then uniquely identifies it like in case 2 or we do both. Is this correct?

Second question in the example I noticed that a return statement was not needed. Why is that?

thanks for the help.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.