There is a javascript object
screen = { title: thisObjectName } You need to assign the variable thisObjectName value equal to the name of the object in this case, this value is equal to screen
There is a javascript object
screen = { title: thisObjectName } You need to assign the variable thisObjectName value equal to the name of the object in this case, this value is equal to screen
If you need to know the name of the object to which you are directly accessing (and for this, a crutch with a title so maybe you need to create an object through the constructor function, and even better through the class? Then you will have access to the name of this class
class Screen { constructor() { this.foo = 'bar' } } const inst = new Screen() console.log(inst.foo) //bar console.log(inst.constructor.name) //Screen if you really need so much to know not the name of the class but the name of the variable that contains the pointer to the object, then you can inject this name through the constructor
class Screen { constructor(name) { this.title = name } } const screen = new Screen('screen') console.log(screen.title) //screen Source: https://ru.stackoverflow.com/questions/840491/
All Articles
x = screen, I will have two absolutely identical links . What name do you want to know "x" or "screen"? - Alexey Ten