Understanding object extension(in Atlas & Ajax) by reading Atlas.js

I've been reading the Atlas.js file in an attempt to understand object extension in Atlas.  Let's assume that I have an object that looks like this:

var obj = new String("Hello World");

If the Atlas.js file has a definition of :

String.prototype.trim = function(){
    return this.trimRight().trimLeft();
}

Then I is an extension to the instance of a string object and I coul call it by the syntax:

obj.trim();

If the Atlas.js file has a definition of:

String.myFunction = function(value){
    // blah, blah, blah
}

then I would make the following call:

String.myFunction(.....);

Its a subtle difference but important to see and know the difference.  It tripped me up for a little while.

1 Comment

Comments have been disabled for this content.