您可以扩展
String原型;
String.prototype.distance = function (char) { var index = this.indexOf(char); if (index === -1) { alert(char + " does not appear in " + this); } else { alert(char + " is " + (this.length - index) + " characters from the end of the string!"); }};…并像这样使用它;
"Hello".distance("H");


