DEV Community

Discussion on: The true prototypial nature beneath "JavaScript classes"

Collapse
 
calvintwr profile image
calvintwr • Edited

Nicely put, I can't agree with you more. The greatest relief in fact, if any, about the ES6 classes syntax, or the TypeScript syntax, is thankfully -- as you rightfully pointed out -- that you can still write simply and readably. Albeit it also can be turned into something really hardcore that looks half-intellectual and half-mangled. I really don't like the people who write such codes thinking that it's your fault you won't understand it.

So I guess I had two main points which is that readability must always be preserved. And yes related to the first love, still can't let go 😂 -- that it should have been proto instead of class, and create instead of new.

Wonderful comment, thanks.

Collapse
 
calvintwr profile image
calvintwr

Btw, your code gives the error of Cannot invoke an object which is possibly 'undefined'. on obj.fullName(). Any idea how to fix that?

Also, why do you need to wrap it in #UsingThePersonClass().

Thread Thread
 
Sloan, the sloth mascot
Comment deleted
 
jwp profile image
John Peters

The wrapping was just to show how to use the Person class.