First of all, since I made the front page of Ajaxian, a lot of new readers joined in. Welcome to all of you. I would also take a moment to explain that Javascript Kata is a technical blog about javascript and though I will talk here and there about ajax, it is not focused on [...]
[I've also written the short answer (for advanced javascripters)] Javascript is using prototypes and is the only language I know that is doing it. What is the idea behind it? Simple. With prototypes, you can extend (add methods/properties) any class you want anywhere you want anytime you want even if you are not the owner [...]
[UPDATE : This post is outdated. Check out the new post on how to create objects.] Javascript is a functional programming language thus having no “real” objects. You can write it the way you want : procedural spag, functional, object or whatever word you know. Why should I write it object-oriented? Because, OO has proven [...]
The intrinsec objects of javascript (String, Number, Date, etc) are missing a lot of handy methods. God knows why. Example, you don’t have a trim() function on a String object. Maybe the developers thought that it was easy enough to write theString.replace(/^\s*|\s*$/g, “”) to trim a string but that’s not the kind of ugly code [...]
[I've also written a longer answer for beginners]Â Prototypes can extend any class you want by adding a property or a method. By calling, [source:javascript] String.prototype.alertMe = function() { alert(this); } [/source] you are adding the method alertMe() to every String object of your application. It uses less memory because javascript creates only one instance [...]