2021年2月2日星期二

How to document as parameter default value

I just want know why

const getElement = (selector, scope = window.document) => scope.querySelector(selector);    const getElement = (selector, scope) => (scope || window.document).querySelector(selector);  

will catch error querySelector is not a function when called it in DOMContentLoaded block. Object window should already exist.

https://stackoverflow.com/questions/66020672/how-to-document-as-parameter-default-value February 03, 2021 at 11:06AM

没有评论:

发表评论