Answers for "3. What are private member variables. in js"

0

3. What are private member variables. in js

function ConstructorCar(initValue) {   this.publicMember = initValue;   let _privateMember = initValue; //private member   this.getPrivateMember = function() { return _privateMember; }   this.setPrivateMember = function(v) { _privateMember = v; }}ConstructorCar.prototype.drive = function() {  //this._privateMember undefined  console.log(“Drive! “+this._privateMember); }const car2 = new ConstructorCar(100);console.log(“getPrivateMember: “+car2.getPrivateMember());car2.drive();
Posted by: Guest on September-20-2020

Code answers related to "3. What are private member variables. in js"

Code answers related to "Javascript"

Browse Popular Code Answers by Language