Inercept variable or property declaration

Viewed 30

I want to intercept and log a statement, everytime a variable or property is declared

As an example after I following code:

let name = "John";
let greet = function(personName) { 
    let greeting = 'hello';
    return greeting + ' ' + personName;
}
greet(name);

I should get following log:

name was created in window scope
greet was created in window scope
personName was created in greet scope
greeting was created in greet scope

Is this possible in javascript?

1 Answers

No, this is not possible in JavaScript.

Related