Object
Update of last article about OOJS
I've updated my last article about javascript.
To instantiate objects, instead of use this very bad code :
var s_arguments="";
//get arguments
for(var i=0; i<arguments.length;i++){s_arguments=s_arguments+"arguments["+i+"]"+",";}
//put arguments in a string
s_arguments = s_arguments.substring(0,s_arguments.length-1);
//Call "constructor" with parameters
eval("myObject."+constructor_name+"("+s_arguments+");");
//I know, eval is evil ;-)
//return instance
return myObject;
use this :
Thanks to the "future" really good book of John Resig "Secrets of the JavaScript Ninja" (http://www.manning.com/resig/) i've found the "true way" : .apply()
if(constructor_name!=null){
myObject[constructor_name].apply(myObject,arguments);
}
No more eval() ;-), more beautiful code
Ugly but useful object oriented javascript notation
Hello, first of all, two things/points(?) :
- on the right hand : i try to improve my english, so sorry for the readers (and Google Translate is my friend)
- on the other hand : i'm not a javascript ninja
We are going to create a framework "à la MooTools".
how to have an almost "real" object-oriented notation in javascript ?
Be careful : The objective of this paper is primarily to "play" with javascript. I'm not sure my code is very clean ;-)
Simple JSON Object : create instance :


Recent comments
1 year 50 weeks ago
1 year 50 weeks ago
1 year 51 weeks ago
1 year 51 weeks ago
1 year 51 weeks ago
1 year 51 weeks ago
1 year 51 weeks ago
1 year 51 weeks ago
1 year 51 weeks ago
1 year 51 weeks ago