The bizarre questions of the interview

1. Yesterday"s interview questions
2. The code is as follows

console.log("this.name", this.name)

/ / run result this.name

console.log("this.age", this.age)

/ / run result this.age undefined
3.

Apr.28,2021

two knowledge points

  1. the this under the global scope points to window, so the this here is window
  2. window.name has a value and is an empty string. Window.age is not worth it, so it is undefined
  3. .

what's weird and what's the problem?

Menu