I found code:
var B = [];
var data = [];
data.push("string");
// ....
B.push(data);
// ...
for each (var A in B){
console.log(B);
console.log(A);
let obj = A[0].split("|", 3);
console.log(objid[0]);
console.log(objid[1]);
}
So B is an array of array, I printed B, it is like:
[
[
"1+!|6789|1234",
"15:00"
],
[
"2+!|1234|4567",
"16:00"
]
]
And I also printed obj
:
["!1+", "6789", "1234"]
["2+!", "1234", "4567"]
which seems correct. And I run this code, it works fine and all functionality works well. But my VScode complains it has syntax error, and I read this:
https://developer.mozilla.org/en-US/docs/Archive/Web/JavaScript/for_each...in
So I tried
- remove
each
and useof
- remove
each
and keep usingin
- keep
each
and useof
for 1, it just crashed and give me error:
SyntaxError: missing ; after for-loop initializer
for 2, I tried to print A
, and I got A
is 0
, which is obviously wrong.
for 3, it just crashed and give me error:
SyntaxError: invalid for each loop
So how should I change it? I guess the old code is correct just deprecated, and I need a replacement that works exact the same way as it. Thanks!