给string添加新的函数

var str = "abcdefg";
String.prototype.constr = function(){
return this.split('').join('-');
}
str.constr();

答案:"a-b-c-d-e-f-g"

原文地址:https://www.cnblogs.com/jymz/p/4180094.html