我对获取数组或对象的键非常困惑。
如何获得密钥:
var arr = [0, 2, 5];
findKey(array, 5);
如何获得密钥;
var obj = {'Abc': {name: 'Sample'}};
findKey(obj, 'Sample'); // Find the index, not abc. Get 0 here.
如何获得密钥:
var obj = {'Room1': ['User1', 'User2', 'User3']};
findKey(obj, 'User1'); // Find the index, not Room1. Get 0 here.