With ES6, we have classes. That’s OOP sugar on JavaScript’s prototypal-inheritance model. There are many tutorials to get started in JavaScript with ES6.
Do you think people are missing essential JavaScript knowledge, and history (prototypes, the eerie working of the this keyword, concepts like composition over inheritance, etc…,) by starting out with ES6, or is ES5 the recommended way to go?
As I was a beginner and a friend right now is trying to learn Javascript, HTML and CSS. I said to him to learn the basics of Javascript that it is used worldwide, can do other stuff on After Effects, Unity, etc (he is a digital artist) and when he finished learning the basics then and only then start learning the advanced of the most common language used today and then to learn something new and something that probably is going to be used in the future.
When I was in college, my first approach with code was pseudo code which everyone does, but then we made the jump to JAVA just like that after learning pseudo code with Alice (move forward, turn right, move back, etc) we made the jump to JAVA importing libraries, using variables named x,y,z, a, b and c without any knowledge of why it is done like that why just those names, why importing something if we have not even begin and that made a hell for me and the whole class, only the ones that already knew something about coding got that and advanced which was about 20% of the class and the teacher moved on just because of that 20% .
After that nightmare I started using Flash and after taking an advanced course of AS3 my eyes were open and found that AS3 probably should've been the best way to go for visual people to learn basics understand what is coding and learning object oriented programming. After learning AS3 and using for a couple years AS3 and seeing it approaching to its dead I switched to Javascript and Unity, I started using scripts to run tasks, detect collision, change objects behaviour, etc and it was a simple change for me.
Why I'm trying to say is that it was easy for me to learn AS3 instead of JAVA, obviously AS3 is simpler but I actually could implemented easily and could see the results of my code in real time and real applications, why? Because I could start experimenting and doing stuff that I thought were crazy but actually were pretty normal, I did a flash app that as a guitar player it would hear how loud you were playing and change the beat of the backing track which would have been an almost impossible task to do on JAVA for me at that moment. So seeing and using in real world applications what you've learned is a big help of growing which is a big down of college, a lot of my friends did not had the same approach to code like me and 95% of them choose a road away from code.
Let me ask you the following: When learning a language, with which version would you begin learning yourself? We are at C++14, C11, Object-Pascal 10.1, JS ES6, HTML5.1, Perl6, etc. If you would pick up one of those without any knowledge, would you start by learning an old version? What advantages would you see in learning an old version?
Sure, the old features might still work, but people actually put a lot a thought into the new features. They exist for a reason. Why should anyone learn the tedious way of having default parameter values in JS ES5, when we have destructuring?
Yes, the old versions are closer to the "basics", but let's think ahead a bit... when ES10 comes out. Would anyone still care about ES5? Would anyone explain JS without explaining things which became available in ES7? Why don't you think about teaching JS 1.0 or ES3? Why ES5? There are a lot of features which are "difficult to understand" (not really) for beginners which were introduced in ES5!
ES6 is not some kind of new thing. It's just the next version of JS as it will be used now and in the future. It's not harder to learn. The only thing making it harder is your mindset, which says that that stuff is new. For a beginner, however, everything is new! ES6 will be regular stuff, and when ES7 is released, that will be the first new and changed stuff for a beginner who learns JS now.
Do not make the mistake of confusing a beginner with 0 knowledge and you with knowledge of the history and legacy ways to handle certain problems.
To put it into a nutshell: Teach the latest and the greatest.
Sure. That's good idea. Not only class in ES6 but all about ES6/ES7
It should be ok, if you teach them all forms of object creation. They must know of .__proto__ and .prototype. Make clear that the class keyword generates a function and not a class in sense of C++/C#/Java/... .
ES6 is not about classes. I never use that useless parody of classes. Many other engeneers also.
Start with ES6 but explain old code and ignore classes, just use what you have mentioned: prototypes and composition. Basically I now do things even simpler without prototypes, "new" at all.
Write simple objects like Dropdown.show(element)
Rodrigo Carranza
Developer
ES6 is not just about the new features, the older ones are also prevalent. So why not teach the nuances of this and prototype if they are also part of the language. Even in next versions, prototype, this, var and others will continue to exist and they are not more ES5 than ES6 or ES7, they are all part of the same language.