en.javascript.info icon indicating copy to clipboard operation
en.javascript.info copied to clipboard

Wrong term used in class article

Open jai-sanghvi opened this issue 1 year ago • 1 comments

In the chapter "Class basic syntax", in the second example of "what is a class" section, on line 15 of the code it is written in the comment that "there are exactly two methods in the prototype" (constructor, sayHi) which I believe is wrong as constructor is a property referencing the constructor function, right? So shouldn't it be "there are exactly two properties" or maybe "two keys"?

Link to the section - https://javascript.info/class#what-is-a-class

jai-sanghvi avatar Nov 22 '24 05:11 jai-sanghvi

Yes, constructor is a reference to a function. So is sayHi. This is how JS functions work. Them being in an object makes them, by definition, methods.

MorganVonBrylan avatar Jan 14 '25 16:01 MorganVonBrylan