From c5411a42d2385762ec879d900dcfdcfc60f54f62 Mon Sep 17 00:00:00 2001 From: Teddy Katz Date: Sun, 4 Feb 2018 17:11:01 -0500 Subject: [PATCH] Suggest using WeakMaps when hidden properties are needed This updates the "trailing or leading underscores" guideline to suggest an better way to make properties hidden, as an alternative to just removing the underscore and making the property public. --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 5a6d678f..d0703471 100644 --- a/README.md +++ b/README.md @@ -2993,6 +2993,11 @@ Other Style Guides // good this.firstName = 'Panda'; + + // good, in environments where WeakMaps are available + // see https://kangax.github.io/compat-table/es6/#test-WeakMap + const firstNames = new WeakMap(); + firstNames.set(this, 'Panda'); ```