javascript入門–Function.prototype.bind()の使い方

サンプルコード:
Function.prototype.bind = function(){
var self = this,
context = [].shift.call( arguments ),
args = [].slice.call( arguments );
return function(){
return self.apply( context, [].concat.call( args, [].slice.call( arguments ) ) );

}
};
var obj = {
name: 'welcome to startnews24 '
};
var func = function( a, b, c, d ){
alert ( this.name );
alert ( [ a, b, c, d ] )
}.bind( obj, 1, 2 );
func( 5, 6 );

JavaScript

Posted by arkgame