其实就是在原型上添加方法,其它类型同理
String.prototype.addPrefix = function (str) {
return str + this;
//自定义前缀加上调用的字符串 hello.world
}
console.log('world'.addPrefix('hello '));
其实就是在原型上添加方法,其它类型同理
String.prototype.addPrefix = function (str) {
return str + this;
//自定义前缀加上调用的字符串 hello.world
}
console.log('world'.addPrefix('hello '));