分享

Array类型

 phpcoder_echo 2016-12-27
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <script>
        //array类型
        /*var color = new Array();
        var colors = new Array(20);//创建一个长度20的数组
        var colorss  = new Array("red","blue","green");
        //var colors=["red","blue","green"];
        console.log(colorss);
        console.log(colorss[0]);
        colorss[2]="black";//修改
        colorss[3]="gray";
        console.log(colorss);*/
        var colorss  = new Array("red","blue","green");
        colorss.length=5;
        //alert(colorss[4]);//设置长度----undefined
        var colo=["red","blue"];
        colo[colo.length]="green";
        colo[colo.length]="black";//可以添加
        console.log(colo);
        //检测数组方式
        value=[];
        if(value instanceof Array){
            alert('yes');
        }
        if(Array.isArray(value)){

        }
        
    </script>
</body>
</html>

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多