Today I was experimenting with regex in JavaScript and stumbled upon a unique data structure that I had never encountered before: an array with some entries having keys. One method that returns such a data structure is the regex match function. Let's take a look at an example:
var re = /SESSID=\w+=;/;
var test = 'SESSID=aaaa=;fjsdfjd';
var arr = test.match(re);
console.log(arr); // ["SESSID=aaaa=;", index: 0, input: "SESSID=aaaa=;fjsdfjd"]
console.log(arr[0]); // SESSID=aaaa=;
console.log(arr['index']); // 0
console.log(arr['input']); // SESSID=aaaa=;fjsdfjd
Can you decipher what's happening here?