Issues Stringifying a multidimensional array with json.js

前端 未结 3 1064
轮回少年
轮回少年 2021-02-08 04:07

I have problems with .stringify(), but I think my JavaScript array must be wrong, here\'s my code:

var questions = new Array();

$(\'#Valid\').hover         


        
3条回答
  •  情书的邮戳
    2021-02-08 05:01

    Fix:

    Replace questions[i]=new Array(); with questions[i] = {}; (or = new Object(); if you really want this "ugly" syntax).

    Explanation:

    Arrays in JavaScript are like arrays in languages like C: They only support integer indexes in the interval [0, array.length).

    For associative arrays, you use objects which are created using the object literal {}.

提交回复
热议问题