ES.nextã¨ãã¦å
¥ã£ã¦ãã¦, ECMAScript 6ã«ãå
¥ããããªæ°é
ãããWeakMap. ã¨ãã訳ã§. WeakMapã¨ã¯ WeakMapã¨ã¯, harmony:weak_maps [ES Wiki] keyã¸ã®åç
§ãå¼±åç
§ keyãä»»æã®Object valueã¯ãªãã§ããã ã¨ãããã®ã§ã. å¼±åç
§ã§ãããã, WeakMapã®keyã«æå®ãããObjectã, weakãªreferenceããããåç
§ããã¦ããªãã£ãå ´å, GCã«ååããã¾ã. ã¾ã, WeakMapã¨ããååãé ããã¡ã§ãã, ã©ã¡ããã¨è¨ãã¨ä¸»æ©è½ã¯ä»»æã®Objectãkeyã¨ãã¦åããã¨ãããã¨ã§ããã. var map = new WeakMap(); var obj = {}; map[obj] = "OK"; // ãã®ã¨ã, toString()ããããããªã. Objectãã¨ãã å¾æ¥ã®O
{{#tags}}- {{label}}
{{/tags}}