JSFiddle - React, Tailwind, and code Playground

by alemarch

JavaScript

//Nav = new Object()

Obj = function() {
    var name= "ciao"
    this.setName = function(x) {name = x}
    this.getName = function(){return name}
    this.whoAmI = function(){
    var ret = "NON LO SO"
        for (var name in this.global) {
            console.log("this. " + name)
      if (this.global[name] == this) 
        ret = name 
          }
     return  ret  
     
     
  } 
     
}
Obj.prototype.global = this

xx = new Object()
p3 = new Obj();
p1 = new Obj();
p2 = new Obj();


r = 12

    p1.setName("pippo")
    //console.log(p1.getName())
    //console.log(p2.getName())
    //console.log(p1.whoAmI()) //p1
    console.log(p3.whoAmI()) //p2