自定义一个reverse方法,浏览器显示Uncaught TypeError: Cannot read property 'concat' of undefined,
是否因为this.charAt[i]为undefine类型,为什么?
<script type="text/javascript">
String.prototype.reverse = function(){
var str = new String();
for(var i=this.length-1; i>-1; i--){
str = str.concat(this.charAt[i]);
}
return str;
}
var str = new String("String");
document.write(str.reverse());