Notes on JavaScript public/private

Imagine we want to write a simulation of a House class with some private fields for storing internal information, and some public getters, setters, and other methods, which can use the internal information in a safe way. I’m going to use this as an example to explore some deeply JavaScripty concepts. This will be our basic chassis, the defining function:

function House()
{
}

Adding a public variable

Crockford tells us that anything added to this will behave like a public instance variable.