我尝试使用运算符扩展本机对象。有用。会不会有你能想到的副作用?
Number.prototype['+++'] = function(n){
return this + (2*n);
};
String.prototype['+'] = function(){
return this += [].slice.call(arguments).join('');
}
alert( 10['+++'](10) ); //=> 30
alert( 'hello '['+']('world ','and ','see you later!') );
//=> hello world and see you later!