以下代码是否在JavaScript中创建全局变量?

时间:2017-04-23 20:16:22

标签: javascript

function User (theName, theEmail) {
    this.name = theName;
    this.email = theEmail;
    this.quizScores = [];
    this.currentScore = 0;
    console.log(this.name);
}
var user1 = new User("Some Name", "tafd@sdf.com");
console.log(name);

上面的代码似乎创建了全局变量。

1 个答案:

答案 0 :(得分:-1)

都能跟得上!因为您的变量是在function

中声明的