what's the difference between Browsers and Node?

前端 未结 2 881
没有蜡笔的小新
没有蜡笔的小新 2021-01-02 18:48

what\'s the difference between Browsers and Node? for instance:

setName.js on Node:

var setName;
setName = function (name) {
    return          


        
2条回答
  •  死守一世寂寞
    2021-01-02 19:27

    Your browser code has the window host object. Node does not have that host object. When you set this.name, you are actually setting it to the window object aka making a global variable.

    window.name === this.name // true

提交回复
热议问题