r/javascript • • May 28 '19

What are some JavaScript things beginners don't know?

333 Upvotes

383 comments sorted by

View all comments

Show parent comments

4

u/circlebust May 28 '19

You use a function to create such an object if you want an object (ES6 Classes are just syntactic sugar over functions), but the other way around doesn't work if you ever want more than one single pencil in your program.

1

u/mkymonkey May 29 '19

What happened to pen?

2

u/el_graveto May 29 '19

I realized that i wrote pencil and pen as the same thing so i changed to not get confusing

1

u/[deleted] May 31 '19

The pen factory got used to create a pencil by leveraging closure?