prototypal-inheritance

In JavaScript, how do I access an object inherited from Array with the [] operator?

I have a situation, where I need to create a new JavaScript object that is inherited from Array. I am using the following code: // Create constructor function. var SpecialArray = function () {}; // Create intermediate function to create closure upon Array's prototype. // This prevents littering of native Array's prototype. var ISpecial...

The value of 'this' inside of a Javascript prototype function used as an event handler

I'm trying to use prototype inheritance in Javascript. The problem with my code below is that when the button is clicked and MyNamespace.MyObj.myEventHandler is called, the value of this is not the instance of MyNamespace.MyObj, but is instead the button that was clicked. Am I structuring things wrong (is there a better way)? Can I so...

[javascript] EXTENDS challenge: preprocessor function macros and class-like oop

Background I've been using the C preprocessor to manage and "compile" semi-large javascript projects with multiple files and build targets. This gives full access to C preprocessor directives like #include, #define, #ifdef, etc. from within javascript. Here's a sample build script so you can test the example code: #!/bin/bash export OP...

Where can I find an example of a large JavaScript project using Crockford's method for prototypal inheritance?

I have read about Crockford's push for using JavaScript in a more obviously prototypal manner (cloning objects to create new ones, never using the "new" keyword). But in the wild, I have never seen anybody use this style for larger projects. Where can I find examples of a large project that uses this style? ...

Prototypal inheritance in Powershell?

Are there any libraries or projects that implement prototypal inheritance for PSObjects in Powershell? ...

Actionscript-3 prototype inheritance

Basically, I want to modify the constructor of the Object class. Since every class extends Object, I hope whenever any object of any class is instantiated, the modified function will be called. So I did this : Object.prototype.constructor = function (){ trace("it was called;"); }; and put a breakpoint on the...

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. Are we stuck writing for the old Object.create? I can't write things that won't work in IE6/7. ...

Javascript: prototypal inherence and super constructor

hi, how can i call super constructor from the inheriting object? for example, i have a simple animal 'class': function Animal(legs) { this.legs = legs; } i want to create a 'Chimera' class that inherits from Animal but sets the number of legs to a random number (providing the maximum number of legs in the constructor. so far i have ...

Inheritance in javascript, variables in the "parent"

I am doing OO javascript for the first time. I have read about inheritance and prototype and thought I had cracked it. Until I discovered this little example. function TestObject(data) { this.test_array = []; this.clone_array = []; this.dosomestuff = function() { for(var i=0; i<this.test_array.length; i++) ...

Standard Inheritance System for node.js and browsers (including IE6)?

Hi I am looking for a Standard Inheritance System that can work in both node.js and browsers. sys.inherits doesn't work in old browsers (Object.create). All js libraries (jquery, extjs, dojo...) have similar but diff inherit systems. (Don't know which one is good for node.js) Want to use one which is simple and may become the "standa...