3 what are private member variables in js

Solutions on MaxInterview for 3 what are private member variables in js by the best coders in the world

showing results for - "3 what are private member variables in js"
Enrique
25 Jun 2019
1function 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();