zoukankan      html  css  js  c++  java
  • JS对象与数组

    $(function () {
        var box = [];
    });


    function obj1() {
        var obj = Object();
        obj.a = "a1";
        obj.b = "b1";
        obj.c = 10;
        alert(obj.a + "|" + obj.b + "|" + obj.c);
    }


    function obj2() {
        var obj = {
            a: 'a1',
            b: 'b1',
            c: 10
        }
        alert(obj.a + "|" + obj.b + "|" + obj.c);
    }
    function array1() {
        var box = [];
        box[0] = "a1";
        box[1] = "b1";
        box.push("c1");
        alert(box);
    }


    function array2() {
        var box = [];
        box[0] = "a1";
        box[1] = "b1";
        box.push("c1");
        alert(box.join(""));
        alert(box.join("!"));
    }


    function array3() {
        var box = ["a", "a1", "a2", "a3"];
        box[0] = "a1";
        box[1] = "b1";
        box.push("c1");
        alert(box);
        box.pop();
        alert(box);
        box.shift();
        alert(box);
        box.unshift("a0");
        alert(box);
    }


    function array4() {
        var box = ["a", "a1", "a2", "a3", "a4", "a5"];
        alert(box+"所有数");
        alert(box.slice(1) + "取从1后面的数");
        alert(box.slice(2, 4) + "取从2到4的数,不包括4");
        alert(box.splice(1, 3) + "取从1开始3个数");
    }

  • 相关阅读:
    15 手写数字识别-小数据集
    14 深度学习-卷积
    5.线性回归算法
    9、主成分分析
    8、特征选择
    4.K均值算法--应用
    6.逻辑回归
    12.朴素贝叶斯-垃圾邮件分类
    13、垃圾邮件2
    大数据应用期末总评
  • 原文地址:https://www.cnblogs.com/cxd1008/p/6372451.html
Copyright © 2011-2022 走看看