+ 7

[JavaScript] Is it a right way to mimic Inheritance in JavaScript?(Without es6 Syntax)

I always use code like following for mimic Class and Inheritance in JS. https://code.sololearn.com/Whu7UlucwVAw/?ref=app But I can't sure of this code. Because I don't know well about class and prototype in JS. It hasn't make a problem since now(I mean so far so good). But I want to clarify this. Can you see my mere code and give me some advice? Any advice or feedback will be very appreciated.

11th Jun 2017, 7:01 AM
김정제(Legacy)
김정제(Legacy) - avatar
7 odpowiedzi
+ 10
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Inheritance_and_the_prototype_chain I started using ES6 with Babel as soon as I learned about it. It's much more intuitive and I see no reason for not using it.
11th Jun 2017, 7:42 AM
Nikolay Nachev
Nikolay Nachev - avatar
+ 8
@Nikolay Nachev Thank you for your comment. You're right. Es6's class feature is available. And I can make class and inheritance with es6. But I want to check my syntax is correct to implement inheritance with es5 syntax. And unfortunately, there are some android devices that don't support es6 syntax. This fact makes me hesitate to use es6 syntax freely.
11th Jun 2017, 4:36 PM
김정제(Legacy)
김정제(Legacy) - avatar
+ 8
"Transcribe" This is what I'm looking for. I can study more deeply with this feature. Thanks a lot!
11th Jun 2017, 4:43 PM
김정제(Legacy)
김정제(Legacy) - avatar
+ 6
@Ben Bright Thank you for your information. :D But maybe I can't use webpack and vanilla.js because I always code in mobile environment... T^T Is there a way to use them in mobile?
13th Jun 2017, 11:36 AM
김정제(Legacy)
김정제(Legacy) - avatar
+ 5
that is where Babel comes in - you can write in ES6 and then Babel can transcribe it to ES5 than you can publish the ES5 version 😃
11th Jun 2017, 4:40 PM
Nikolay Nachev
Nikolay Nachev - avatar
+ 5
@Legacy as sir @Nikolay has said already, I will also suggest you learn the basics of setting up webpack with babel-loader and es2015 preset to ease the conversion of es2015 to vanilla js. So you code all in es2015 and your content gets transcribed or transpiled into vanilla js code.
13th Jun 2017, 11:14 AM
Benneth Yankey
Benneth Yankey - avatar
+ 4
@Legacy I am not sure you can do that on mobile, for procedural code practices mobile is ok. But for complete project you need a computer.
13th Jun 2017, 12:43 PM
Benneth Yankey
Benneth Yankey - avatar