MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/javascript/comments/btxz72/what_are_some_javascript_things_beginners_dont/epagzp1/?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? 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
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
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
2
I realized that i wrote pencil and pen as the same thing so i changed to not get confusing
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?