How to print only the `this` object's name , and not it's contents in javascript?

  • A+

consider the function:

function foo() {   console.log(this); }  foo();

How to print only the this object's name (window or global....etc), and not it's contents?


You can print an objects name in js with

function foo() {   console.log( }  foo()

Will print Window


:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: