Private members help protect a component’s internal workings from unintended use. JavaScript underscores can signal that a member is internal, but they restrict access by convention, not by language enforcement. section 8.1 section 3.2
Internal method versus public API
A component’s add() method updates its data model and then calls addItemToUI(). Calling addItemToUI() directly can add an element that disappears when the component redraws. Use the intended API rather than an internal method. section 8.1
Listing 3.7. Getters and setters for our component’s configurable options
set apiKey(value) { #1
this._apiKey = value;
this.doSearch();
}
set searchTerm(value) { #2
this._searchTerm = value;
this.doSearch();
}
The setters expose apiKey and searchTerm while storing values in underscore-prefixed fields. section 3.2











