iaapi.blogg.se

You dont know js prototypal inheritance
You dont know js prototypal inheritance





you dont know js prototypal inheritance
  1. YOU DONT KNOW JS PROTOTYPAL INHERITANCE MODS
  2. YOU DONT KNOW JS PROTOTYPAL INHERITANCE CODE

If we can be blissfully ignorant of the mechanics underneath, that means we made a good abstraction. Python has been around longer than even Java, and all this time its inheritance has been objects linked to other objects.

you dont know js prototypal inheritance

How could that be? Turns out Python's class and inheritance mechanics match what we JavaScripters would call prototypes. Later I found out Python classes could be monkey patched, and that already existing instances would immediately reflect the new behavior of the patch.

you dont know js prototypal inheritance

Python has classes and inheritance, and at first I just assumed they were Java/C++ style classes. The ES6 classes for example look a lot simpler but seem like it hides a little of the prototypal nature or javascript.Ī while back, I was using Python. This part isn't really related to ES5 vs ES6, but the JS ecosystem doesn't show any signs of slowing down.

YOU DONT KNOW JS PROTOTYPAL INHERITANCE CODE

But if you don't expect to have to read or write pre-ES6 code anytime soon, then just stick to the new stuff.Īt the time, I hated the amount of things that kept being introduced with javascript like react, yarn, vue etc and the whole ecosystem put me off If you expect to be working on a pre-ES6 codebase, then obviously yes it's worth learning. Legacy code doesn't suddenly become legacy overnight. I don't know if using "var" is consistently considered a "bad" practice but in my eyes it is not a desired practice.ĭepends on your job. I am picturing someone making a counter-point where they illustrate that hoisting could be used in some kind of fancy/hacky way to accomplish a goal in a specific case but I would have to assume that whole case ought to be avoided in the first place. At least nothing that I can think of that doesn't sound hacky to me. Var will still do hoisting and I always believed that one of the worst parts of var is how hoisting can lead to confusing code behaviour.Ĭan you understand var and still use it safely, yes, but does it offer some important that const and let do not? Not that I know of. I think the creation of let and const are not only there for safer coding but also for better communication of intentions in code. "let" is a good way to show that you will be changing this variable later in the code. "const" is a good way to explicitly make a variable that you do not want to change after it's made. I think it's good to know some differences, like arrow functions as class properties can prevent you from needed to bind your function to "this" when making react components.īut I don't know of a case where you would use var when you could use let or const. I don't see anything wrong with writing a normal function and I often do. That is just a "nice to have" in some people's opinion.

you dont know js prototypal inheritance

Personal blog posts that are relevant to the subreddit's stated subject matter don't need prior approval (and are encouraged!).įor functions you don't have to use fat arrow at all.

YOU DONT KNOW JS PROTOTYPAL INHERITANCE MODS

If you want to post something self-promotional, please message the mods first. Titles that begin with "hey guys" will be removed. Good Titles - Write a descriptive title.If you want to post something you created, that is OK, but posting your YouTube channel every single day (unless you're making a high quality video everyday!) or similar behavior is a no-go. No posts that only serve to get clicks or subscribers. If you’re asking for help, include enough information for others to recreate your problem. With a nod to practicality, questions and posts about HTML, CSS, and web developer tools are also encouraged. Everyone should feel comfortable asking any and all JavaScript questions they have here. Armed with this knowledge, you can become a true JavaScript master.This subreddit is a place for people to learn JavaScript together. Like other books in the “You Don’t Know JS” series, this and Object Prototypes dives into trickier parts of the language that many JavaScript programmers simply avoid. You’ll learn how they work and why they’re integral to behavior delegation-a design pattern in which objects are linked, rather than cloned. This concise, in-depth guide takes you inside JavaScript’s this structure and object prototypes. No matter how much experience you have with JavaScript, odds are you don’t fully understand the language.







You dont know js prototypal inheritance