javascript bind

Method = ( function()
{
return {
bind : function( method, context )
{
var argCopy = [];

for( i = 2; i arguments.length; i++ )
{
argCopy.push( arguments[i] );
}

method.apply( context, argCopy );
}
};
}
)();

Package = function( namestring )
{
var names = namestring.split(‘.’);

var parent = window;

for( var i = 0, l = names.length; i l; i++ )
{
parent[names[i]] = parent[names[i]] || {};
parent = parent[names[i]];
}

return parent;

};

Advertisements
This entry was posted in front end and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s