将数组插入哈希jquery

时间:2015-10-13 09:40:18

标签: javascript jquery

我有一个类似[“2”,“3”]的数组到user_id:[“2”,“3”]和另一个像[“4”,“5”]这样的数组到admin_id:[“4”, “5”]到哈希式  TOTAL_USERS:USER_ID:[ “2”, “3”],admin_id:[ “4”, “5”] 像这样可以在jquery吗?

先谢谢

1 个答案:

答案 0 :(得分:1)

试试这段代码。

var userIds = ["2","3"];
var adminIds = ["4","5"];
var obj = {};
obj.total_users = {
  user_id: userIds,
  admin_id: adminIds
};
alert(JSON.stringify(obj));