Saturday, January 5, 2008

Next! - Prototyping

Hi again, here is my second post about my library!

Well this post is not talking about Next! directly but talks about my way to look at JavaScript.

Theres allot of buzz about un-obstructive JS, they mean that we should not extend core objects and we should put everything in packages, and don't pollute main scope ( window ) with variables etc...

I agree in some aspects, but i don't like to loose the main advantage of JavaScript, extending Core objects, ok that makes my library breaks compatibility with other libraries. Thats bad, i know.

Lets look on this, for start my library i do:
var next={};
For now on i put all my vars and functions on that context, if i do everything in un-obstructive way i would have todo something like this:
return string.indexOf(what)===0;
//for use it we do:
return this.indexOf(what)===0;
//for use it we do:
Now... doesnt the second aproach look better and eseyer to create and use?
Not only to talk about where we can resolve missing stuff in diferent browsers!
For example JavaScript 1.6 suports some new array extensions:
They are great! But not all browsers suport them yet, so we can create them for browsers thatdot suport!

So on Next! library i am going to use prototyping on core types to make js more extended.

Its all for now, next ime i am going to talk about inherance and Class stuff

No comments: