testing - Is it OK to name a function parameter window in JavaScript? -


is ok name function parameter window in javascript (if said parameter correspond window object @ runtime)?

in short want inject window object function improve testability, aware hide direct access window object within function said parameter.

window not reserved keyword, name parameter window if wanted to.

using variable/argument common in iife's minimizing , keeping value of window constant, see things like

(function(window, undefined) {     // code  })(window); 

and there no issues this, other maybe confusion if decide use like

function stuff(window) {     window.value = 'woot'; }  stuff( document.queryselector('input') ); // confusing ? 

which confusing.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -