YanoRyuichi.com/
Wiki
Blog
GitHub
Sandbox
開始行:
* オブジェクトのキー名を正規表現で調べる [#sf73c76a]
const data = {id1: 100, name: 'foo', id2: 200};
const val = (() => {
const key = Object.keys(data).find(x => x.match(/^id...
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(/^i...
console.log(val);
=> 100
** 参考 [#l0435c8e]
https://github.com/micromatch/micromatch
終了行:
* オブジェクトのキー名を正規表現で調べる [#sf73c76a]
const data = {id1: 100, name: 'foo', id2: 200};
const val = (() => {
const key = Object.keys(data).find(x => x.match(/^id...
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(/^i...
console.log(val);
=> 100
** 参考 [#l0435c8e]
https://github.com/micromatch/micromatch
ページ名: