Skip to content Skip to sidebar Skip to footer
Showing posts with the label Prototype

Javascript "this" Losing Context In Ie

The following works fine in firefox/safari/chrome, in IE, 'this' appears to be losing conte… Read more Javascript "this" Losing Context In Ie

Extending Object Literal

var x = { name: 'japan', age: 20 } x.prototype.mad = function() { alert('US… Read more Extending Object Literal

Object.prototype In Javascript

I have some JavaScript code that defines a function getElementsByAttribute as follows: Object.proto… Read more Object.prototype In Javascript

Why Is Prototype Function 40x Slower Than The Default Declared Function?

I've played with jsperf.com and found that prototyped function is 40x slower than 'default&… Read more Why Is Prototype Function 40x Slower Than The Default Declared Function?

Javascript Function With Prototype Within Parent Function Prototype

Is this even possible? function foo() { // do stuff } foo.prototype = { // stuff... bar… Read more Javascript Function With Prototype Within Parent Function Prototype

Overriding Array Literal In Javascript

My app (a custom web browser) is injecting code into a page that has a modified Array prototype (sp… Read more Overriding Array Literal In Javascript

How To Overwrite Addeventlistener In Firefox 3.x?

im making a greasemonkey userscript which puts all kinds of shims and polyfills in the page for old… Read more How To Overwrite Addeventlistener In Firefox 3.x?

Extending Knockout Viewmodels With Prototype

If a viewmodel is already defined, either manually or automatically with mapping plugin, is there a… Read more Extending Knockout Viewmodels With Prototype

Trigger One Prototype Function From Another (including Itself)

The Problem I have created a constructor called Game. Then, I tried to expand it's functionalit… Read more Trigger One Prototype Function From Another (including Itself)

Javascript Using Prototype How Can I Set The Value Of "this" For A Number?

So if we can get past the 'should you?' question ... does anyone know how to set the value … Read more Javascript Using Prototype How Can I Set The Value Of "this" For A Number?

Why Defining Properties In The Prototype Is Considered An Antipattern

I often see this pattern to define javascript objects function Person(name) { this.name = name;… Read more Why Defining Properties In The Prototype Is Considered An Antipattern

Call/bind/apply Vs Prototype

In the following code: function User(name) { this.name = name; } var user = new User('Jaso… Read more Call/bind/apply Vs Prototype

Extending Native Elements In Javascript Via Prototype?

Would you consider extending the native elements via the prototype dangerous? I see some frameworks… Read more Extending Native Elements In Javascript Via Prototype?

Using Prototype Functions In Higher Order Functions In Javascript

I'm trying to concat an array of arrays using reduce and I figured that I could use the Array.p… Read more Using Prototype Functions In Higher Order Functions In Javascript

Why Is Foo.hasownproperty('__proto__') Equal To False?

var foo = { bar : 5 } Why is foo.hasOwnProperty('__proto__') equal to false? It can'… Read more Why Is Foo.hasownproperty('__proto__') Equal To False?

What's Wrong With A Javascript Class Whose Constructor Returns A Function Or An Object

When I use new to instainciate an instance of a certain class, I got the actual instance. When the … Read more What's Wrong With A Javascript Class Whose Constructor Returns A Function Or An Object

Node.js Change Number Object Value Inside Prototype

I want to add a new method to Number type, and then use it to change its own value. I write below c… Read more Node.js Change Number Object Value Inside Prototype

Accesing `this` Value When The Prototype Contains An Object?

I have a class like this: function Foo() { this._current = -1; } Foo.prototype.history = {}; … Read more Accesing `this` Value When The Prototype Contains An Object?

How Value To __proto__ Is Assigned In Javascript?

Recently I have been playing with javaScript prototype object and came across below example. functi… Read more How Value To __proto__ Is Assigned In Javascript?

What's Wrong With This Style Of Coding Javascript? (closures Vs. Prototypes)

We have been debating how best to handle objects in our JS app, studying Stoyan Stefanov's book… Read more What's Wrong With This Style Of Coding Javascript? (closures Vs. Prototypes)