When declaring variables at the top of the JavaScript function, is it best practice to set them equal to null, or leave as 'undefined'? Another way to ask, what circumstances call for each option below?
Option A:
var a = null,
b = null;
Option B:
var a,
b;
b= nullversion unless it actually matters that the variable values arenullinstead ofundefined.var a, b;mightn't always leave itundefined. In former IE versions, you would need to change that piece of code tovar a = undefined, b = undefined;, otherwise your code would generate an error while trying to access it (even if you were just trying to simply check if it has some value withif (a && b), for example). In that case, an unset variable differs fromundefined.