导航栏: 首页 评论列表

数组push一个new function遇到的坑

默认分类 2015/01/22 06:19

数组push一个new function遇到的坑.

<script type="text/javascript">
<!--
function doit(){
    //Todo
    var exist = false;
    for (var i=0,ilen=arr.length; i<ilen; i++) {
        if (arr[i] instanceof bb) {
            exist = true;
            break;
        }
    }
    if (!exist) {
        arr.push(new bb());
    }
}

function bb() {
    arr.push(this);
}

var arr = [];

//-->
</ script>
<button type="button" onclick="doit()">doit</button>


>> 留言评论