Home » common misunderstandings

common misunderstandings

Private Variables in JavaScript

Because JavaScript uses prototype-based inheritance, there is no keyword to define a member as “private” or “protected”. Either the object has a member, or it doesn’t, and you can access that member from anywhere you can access the object. Do not despair! There is a way to implement private variables… using another feature of the language: closures!

Closures

Closures are fairly simple, but frequently misunderstood. What you need to know for now, is that a closure allows you to reference an outer variable from within a function, even when the function is called from another context.

This will make more sense when you see some code.Read More »Private Variables in JavaScript

Inheritance in JavaScript

Native JavaScript inheritance is prototypical. For one, this means that you don’t inherit from classes, you inherit from objects. You don’t define classes and instantiate them. Instead, you create objects and use them as a “prototype” or “base” for your own object instances.

In JavaScript, this is facilitated with the mechanisms called “prototype” and “constructor”.
Read More »Inheritance in JavaScript

Useful JavaScript Features You Aren’t Using

JavaScript is one of the most widely used and misunderstood programming languages in existence. Nearly every personal computer and mobile device in the world can interpret it, and nearly every developer (and non-developer) that has made a website has written it, some without knowing it!

If you call yourself a JavaScript developer, then here are some things that the language can do that you need to know about, whether you use them or not! If you are using them, then you should understand them!
Read More »Useful JavaScript Features You Aren’t Using