As Nina Scholz stated in her comment, it's a destructuring assignment.
If data2
was an array of [1, 2, 3]
, then var [checkbox, payee, amount] = data2;
is the same as:
var checkbox = data2[0]; // 1
var payee = data2[1]; // 2
var amount = data2[2]; // 3
Rest parameter
You can using destructuring with rest parameter like in the example below, to save multiple elements into an array.
const digits = [1, 2, 3, 4, 5];
const [one, ...other] = digits;
console.log(one);
console.log(other);
Omitting values
You can ignore the values you're not interested in, like this:
const myArray = ["car", "cat", "house", "dog", "window", "mouse"];
const [, cat, ,dog, , mouse] = myArray;
console.log(cat, dog, mouse);
or like this:
const myArray = ["John", "Mary", "Steve", 0, 1, 2];
const [name1, name2, name3] = myArray;
console.log(name1, name2, name3);