MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/javascript/comments/btxz72/what_are_some_javascript_things_beginners_dont/ep6jcix
r/javascript • u/[deleted] • May 28 '19
383 comments sorted by
View all comments
Show parent comments
4
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?
1
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?
2
I realized that i wrote pencil and pen as the same thing so i changed to not get confusing
The pen factory got used to create a pencil by leveraging closure?
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.