JSFiddle - React, Tailwind, and code Playground

by Deepak Kumar

JavaScript

function customobject(){
    this.value = 2;
}

customobject.prototype.inc = function(){
    this.value++;
}

function changer(func){
    func(); 
}

var o = new customobject();
alert(o.value); // o.value = 2

o.inc();
alert(o.value); // o.value = 3

changer(o.inc);
alert(o.value); // Still 3 why not 4