Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Feb 2006
    Posts
    60
    Thanks
    2
    Thanked 0 Times in 0 Posts

    simple enumeration question

    Hi
    According to JavaScript: The Good Parts, "The for in statement can loop over all of the property names in an object. The enumeration will include all of the properties—including functions and prototype properties", but when I try:

    Code:
    var x;
    var mystr = new String("abc");
    for (x in mystr) {
        document.writeln(x + ':' + mystr[x] + "<br/>");
    }
    in IE I get nothing output at all and in FF2 I get 0:a 1:b 2:c -but no functions. I was wondering why all the properties of the String object e.g. chartAt() and indexOf() etc. aren't displayed?

    Thanks!

  • #2
    Regular Coder
    Join Date
    Jun 2007
    Location
    USA
    Posts
    527
    Thanks
    26
    Thanked 74 Times in 72 Posts
    Many built-in properties do not enumerate.
    Trinithis

  • #3
    New Coder
    Join Date
    Feb 2006
    Posts
    60
    Thanks
    2
    Thanked 0 Times in 0 Posts
    thanks


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •