MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/javascript/comments/btxz72/what_are_some_javascript_things_beginners_dont/epnvmq8/?context=3
r/javascript • u/[deleted] • May 28 '19
383 comments sorted by
View all comments
Show parent comments
3
What is the advantage to using a function instead of declaring the pencil as an object with its own properties and methods?
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? 1 u/[deleted] May 31 '19 The pen factory got used to create a pencil by leveraging closure?
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? 1 u/[deleted] May 31 '19 The pen factory got used to create a pencil by leveraging closure?
1
What happened to pen?
1 u/[deleted] May 31 '19 The pen factory got used to create a pencil by leveraging closure?
The pen factory got used to create a pencil by leveraging closure?
3
u/theycallmeepoch May 28 '19
What is the advantage to using a function instead of declaring the pencil as an object with its own properties and methods?