var str=Array.prototype.slice.call("strings");
alert(str[0] +"|"+str.concat+"|"+(str instanceof Array));//IE6 下str[0]为什么是undefined ?

解决方案 »

  1.   

    不光是ie6,所以ie都不行,不支持这样把一个字符串转换为数组.
      

  2.   

    var str=Array.prototype.slice.call(["strings","aaa"]);
    alert(str[0] +"|"+str.concat()+"|"+(str instanceof Array));
      

  3.   

    str instanceof Array这个结果为true哦
      

  4.   


    虽然是为true,但并不能把你传递的字符串转化为数组.
      

  5.   

    str已经是一个数组了,但里面的元素是undefined的,
      

  6.   

    str.lengthalert(str[0] +"|"+str.concat+"|"+(str instanceof Array)+"|"+str.length);
      

  7.   

    str.length确实是string的长度,为什么他没有像ff那样将string拆分后对号入座,你去问ms吧.
    这就是邪恶的IE.
      

  8.   


    <script type="text/javascript">
    <!--
    var str=Array.prototype.slice.call("strings".split('')); // 
    alert(str[0] +"|"+(str instanceof Array));
    //-->
    </script>
      

  9.   

    呵呵,不错,不过split了,就不用再Array.prototype.slice.call了
      

  10.   


    Array.prototype.slice.call 既然是Array的call 就要用数组呀 当然在FF下可以使用类数组 如NodeList之类