Follow me on Twitter at Twitter.com/wbm
FYI, I'm blogging most of my stuff over at More Wally now.
You might want to add my rss feed to your reader at:http://morewally.com/cs/blogs/wallym/rss.aspx
Understanding object extension(in Atlas & Ajax) by reading Atlas.js - Wallace B. McClure

Wallace B. McClure

All About Wally McClure - The musings of Wallym on Web, HTML5, Mobile, MonoTouch for iPhone, MonoDroid for Android, and Windows Azure.

News

Personal Blog

Work Blog

.NET

Book Authors

Business

Family

Friends

Georgia Tech Bloggers

Personal

Archives

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.
Posted: Sep 11 2006, 11:11 AM by Wallym | with 1 comment(s)
Filed under:

Comments

Aaron Seet (icelava) said:

So "prototype" is an indicator to mean the method is an _Instance_ method, rather than Static. Ah, I am getting closer to understanding what that term is about.

# February 4, 2007 9:45 PM
Leave a Comment

(required) 

(required) 

(optional)

(required)