WeakMaps are a new feature in ECMAScript 6 that, among many other things, gives us a new technique to hide private implementation data and methods from consumers of the public API we choose to expose.
WeakMaps are used instead of normal Maps or the combination of instance IDs and a plain object so that we neither hold onto references and leak memory nor need to introduce manual object lifetime management.
The WeakMap privates pattern is the best choice when you really need to hide private implementation details from public API consumers.
Your new post is loading...
follow-up:
http://www.nczonline.net/blog/2014/01/21/private-instance-members-with-weakmaps-in-javascript/