JavaScript和Node JS之间的区别[关闭]

我是JavaScript编程/ Node JS的新手,对几件事感到困惑

  1. I work on a NodeJS/Protractor test framework and I tried to run some JavaScript code such as

    document.querySelector
    

    but it did not work, it returned an error instead but in the same file other Javascript code such as switch/if statements work without any issues, what's the reason behind that?

  2. Will any JavaScript code work on a Node.js project/environment?

  3. What's browser.executescript used for?

  4. Is Protractor capable of executing any JavaScript code?