Difference between Array.length = 0 and Array =[]?

前端 未结 3 2216
无人及你
无人及你 2020-11-29 20:47

Can some one explain the conceptual difference between both of them. Read somewhere that the second one creates a new array by destroying all references to the existing arra

3条回答
  •  再見小時候
    2020-11-29 21:39

    Are you sure it really works?

    I did a little experiment here, and trying to "add" an Array with a String resulted in a string.

    function xyz(){
        var a = [];
        alert(typeof(a+$("#first").html()));
        // shows "string"
    }
    

    http://www.jsfiddle.net/4nKCF/

    (tested in Opera 11)

提交回复
热议问题