iugo
V2EX  ›  问与答

JavaScript 怎样快捷创建多维数组?

  •  
  •   iugo · Aug 2, 2015 · 2685 views
    This topic created in 4115 days ago, the information mentioned may be changed or developed.
    目前我是这样的:

    var level = new Array();
    level[0] = new Array();
    level[0]['num'] = 99;
    level[0]['name'] = '无等级';
    level[1] = new Array();
    level[1]['num'] = 365;
    level[1]['name'] = '女汉子';
    5 replies  •  2015-08-03 02:47:04 +08:00
    g0thic
    g0thic
    Aug 2, 2015❤️1
    1
    var level = [{num:99,name:'无等级'},{num:365,name:'女汉子'}]
    直接这样?
    yyfearth
    yyfearth
    Aug 2, 2015❤️1
    2
    就算 new Array() 都不应该出现
    iugo
    iugo
    OP
    Aug 2, 2015
    3
    @g0thic
    @yyfearth 是我被扭曲了.
    vfasky
    vfasky
    Aug 2, 2015 via iPhone
    4
    @iugo 目测php写多了😄
    yyfearth
    yyfearth
    Aug 3, 2015
    5
    @vfasky 稍微新一点的 php 也不用这样麻烦的创建array啊
    倒是比较像老版本 Java 或者 C/C++
    新一点的 Java 也可以用语法来直接构建了 不过还不是特别方便
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   751 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 35ms · UTC 23:18 · PVG 07:18 · LAX 15:18 · JFK 18:18
    ♥ Do have faith in what you're doing.