Menu

#3 toCharArray method error of StringPrototype

v2.0
open
prototype (1)
5
2007-09-22
2007-09-22
eye_of_back
No

<script src="jsjava-2.0.js"></script>
<script>
var arr="abc".toCharArray();
document.write(arr.length);
</script>

run the code in IE browser 6.0 and a error will occurs in the line 3.

I find error in the StringPrototype class:

String.prototype.toCharArray=function(){
if(this==undefined){//ERROR here!
return null;
}
var length=this.length;
var chars=new Array(length);
for(var i=0;i<length;i++){
chars[i]=this.charAt(i);
}
return chars;
};

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.