All Questions

926
votes
3answers
137621 views

What are the nuances of scope prototypal / prototypical inheritance in AngularJS?

The API Reference Scope page says: A scope can inherit from a parent scope. The Developer Guide Scope page says: A scope (prototypically) inherits properties from its parent scope. So, doe...
538
votes
20answers
106451 views

__proto__ VS. prototype in JavaScript

This figure again shows that every object has a prototype. Constructor function Foo also has its own __proto__ which is Function.prototype, and which in turn also references via its __proto__ p...
79
votes
6answers
17346 views

Why is extending native objects a bad practice?

Every JS opinion leader says that extending the native objects is a bad practice. But why? Do we get a perfomance hit? Do they fear that somebody does it "the wrong way", and adds enumerable types to ...
12
votes
3answers
1441 views

Crockford's Prototypal inheritance - Issues with nested objects

I've been reading "Javascript: The Good Parts" by Douglas Crockford - and while it's a bit extreme, I'm on board with a lot of what he has to say. In chapter 3, he discusses objects and at one poin...
18
votes
5answers
22439 views

Properties of Javascript function objects

I have a JavaScript function object as; var addNum = function(num1, num2) { return num1 + num2; } Now if I try to access addNum.divide() I wanted to understand the prototype chain for t...
8
votes
3answers
5385 views

Object.defineProperty in ES5?

I'm seeing posts about a 'new' Object.create that makes enumeration configurable. However, it relies on a Object.defineProperty method. I can't find a cross browser implementation for this method. ...
9
votes
3answers
4426 views

Check if a constructor inherits another in ES6

I have a situation where I need to check if a constructor (X) has another constructor (Y) in its prototype chain (or is Y itself). The quickest means to do this might be (new X()) instanceof Y. That ...
84
votes
10answers
80220 views

Good Example of JavaScript's Prototype-Based Inheritance

I have been programming with OOP languages for over 10 years but I'm learning JavaScript now and it's the first time I've encountered prototype-based inheritance. I tend to learn fastest by studying g...
19
votes
6answers
9766 views

Performing inheritance in JavaScript

Now while I know that you can not perform inheritance like you would in C#, I have seen it mentioned on the Internet that it is kind of possible. If it's not possible using plain JavaScript code then ...
24
votes
4answers
5902 views

Is John Resig's Javascript inheritance snippet deprecated?

I'm looking for a simple way of creating two classes, one inheriting from the other, and the child redefining one of the parent's methods, and inside the new method, calling the parent's. For example...

Previous Next