EasyClick JavaScript 键值对存值
Posted Mr -老鬼
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了EasyClick JavaScript 键值对存值相关的知识,希望对你有一定的参考价值。
EasyClick javascript 键值对存值
瞎写的 键值对存数组对象。
示例代码
//测试例子 瞎写的 勿喷
let a = {};
let b = []
let c = []
// 存储假数据
for (let i = 0; i < 70; i++) {
c[i] = i;
}
logd(c.toString());
// 将假数据的值存入键值对 "Y0":b数组 按顺序取7个值存进b数组 依次类推
for (let i = 0; i < 70; i++) {
Y(i, 0);
Y(i, 1);
Y(i, 2);
Y(i, 3);
Y(i, 4);
Y(i, 5);
Y(i, 6);
Y(i, 7);
Y(i, 8);
Y(i, 9);
}
// 循环 存b 值 0-7 这样
function xunhuan(xiaoY, daY, i, d) {
if (i >= xiaoY && i < daY) {
let ii = 0;
for (let k = xiaoY; k < daY; k++) {
b[ii] = c[k]
a["Y" + d] = b
ii++;
}
}
}
// 控制存储位置函数 Y0 -Y9
function Y(i, Y) {
b = [];
switch (Y) {
case 0:
xunhuan(0, 7, i, Y);
break;
case 1:
xunhuan(7, 14, i, Y);
break;
case 2:
xunhuan(14, 21, i, Y);
break;
case 3:
xunhuan(21, 28, i, Y);
break;
case 4:
xunhuan(28, 35, i, Y);
break;
case 5:
xunhuan(35, 42, i, Y);
break;
case 6:
xunhuan(42, 49, i, Y);
break;
case 7:
xunhuan(49, 56, i, Y);
break;
case 8:
xunhuan(56, 63, i, Y);
break;
case 9:
xunhuan(63, 70, i, Y);
break;
}
}
logd(JSON.stringify(a));
输出结果
[2021-05-01 22:40:59.458]【远程设备】0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69
[2021-05-01 22:40:59.481]【远程设备】{"Y0":[0,1,2,3,4,5,6],"Y1":[7,8,9,10,11,12,13],"Y2":[14,15,16,17,18,19,20],"Y3":[21,22,23,24,25,26,27],"Y4":[28,29,30,31,32,33,34],"Y5":[35,36,37,38,39,40,41],"Y6":[42,43,44,45,46,47,48],"Y7":[49,50,51,52,53,54,55],"Y8":[56,57,58,59,60,61,62],"Y9":[63,64,65,66,67,68,69]}
我是Mr-老鬼、QQ1156346325 。交流QQ群:620028786,647082990
------------------------------------------------版权声明------------------------------------------------------
本文版权所有~Mr-老鬼 ~转载请注明原文地址
免责声明:本文所有的教程仅限交流学习使用不得用于违法用途,造成的法律后果本人不承担责任。
以上是关于EasyClick JavaScript 键值对存值的主要内容,如果未能解决你的问题,请参考以下文章
javascript 将键值对添加到JavaScript对象