and I want to choose the index where the table is case insensitive
let table = {'tAble': [{'number': 1}],'CHair': [{'number': 2}]}
console.log(table[/table/i])
and I want to choose the index where the table is case insensitive
let table = {'tAble': [{'number': 1}],'CHair': [{'number': 2}]}
console.log(table[/table/i])
You can do this using Object.keys
table[Object.keys(table).find(x=> /table/i.test(x))]
Here you're getting an array of all keys, and then using find to test them with your RegExp, and then using the found key to retrieve the correct property of the object.
let index = Object.keys(table).findIndex(key => key.toLowerCase() === 'table');
let table = {'tAble': [{'number': 1}],'CHair': [{'number': 2}]}
let key = (Object.keys(table).find(i=>i.toLowerCase() === 'table'));
console.log(key)
console.log(table[key])