Encapsulation in JavaScript with getter and setter
问题 I realise that this has been asked but have researched and failed - sorry! I want to implement encapsulation in JS as simply as possible. I realise that any 'var' in the class will be private. I am simply unsure how to GET and SET values of any private var. In the example below the interface methods for GETTING and SETTING 'colour' do not work because those functions cannot access the private 'colour' property of the object. I cannot find a clear example showing me how to implement this. I am