Why are certain function calls termed “illegal invocations” in JavaScript?

后端 未结 4 1308
情话喂你
情话喂你 2020-11-28 05:11

For example, if I do this:

var q = document.querySelectorAll;

q(\'body\');

I get an \"Illegal invocation\" error in Chrome. I can\'t thin

4条回答
  •  离开以前
    2020-11-28 06:02

    One more concise solution:

    const q=s=>document.querySelectorAll(s);
    q('body');
    

提交回复
热议问题