#author("2020-06-02T20:00:25+09:00","default:ryuichi","ryuichi")
#author("2020-06-02T20:02:28+09:00","default:ryuichi","ryuichi")
* オブジェクトのキー名を正規表現で調べる [#sf73c76a]
const data = {id1: 100, name: 'foo', id2: 200};
const key = data[Object.keys(data).find(x => x.match(/^id[0-9]/))];
console.log(key);
const val = (() => {
const key = Object.keys(data).find(x => x.match(/^id[0-9]/));
return data[key];
})();
console.log(val);
=> 100
const data = {id1: 100, name: 'foo', id2: 200};
const val = data[Object.keys(data).find(x => x.match(/^id[0-9]/))];
console.log(val);
=> 100
** 参考 [#l0435c8e]
https://github.com/micromatch/micromatch