1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
'use strict'; const p = console.log; const createDict = () => { const dict = []; const set = (k, v) => { dict[k] = v; }; const get = (k) => { return dict[k]; }; const del = (k) => { delete dict[k]; }; const keys = () => { return Object.keys(dict); }; return { set, get, del, keys, }; }; const main = () => { const d = createDict(); d.set('keyA', 'valueA'); d.set('挨拶', 'こんにちは'); p(d.get('挨拶')); p(d.keys()); }; main(); |
1 2 |
こんにちは [ 'keyA', '挨拶' ] |