Mini Program: how to add an array to an object and an object to an array?

how to add srr to arr, and then arr1 to obj

var arr=[];

var obj={};

let str = { "addtime": "1543021769" };

var arr1 = [ "a","b","c","c" ];



add elements to the array: arr.push (str)
to add elements to the object, you must first set the attribute name, for example: obj.arr1 = arr1


the array can be added directly with push, such as var a = {CRAV 1}, var b = [], b.push (a) is fine. If you add an array to the object, just treat the array as a value in the key-value pair. For example, a.b = b is fine

Menu