You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The idea here seems to be to make sure undefined is really undefined by not passing it into the actual call. However, I believe this is no longer necessary in ES5+ compliant browsers.
These days, it's actually safer not to do it as it introduces a way for a developer to introduce a local variable named undefined by accidentally calling the function with too many arguments. MDN seems to advise against that and personally, I agree.
Later in the same script, there's a comment saying:
// undefined is used here as the undefined global variable in ECMAScript 3 is
// mutable (ie. it can be changed by someone else). undefined isn't really being
// passed in so we can ensure the value of it is truly undefined. In ES5, undefined
// can no longer be modified.
I understand that the fact the template still uses this practice is a conscious decision based on the team's belief in continuing to do it to cater for pre-ES5 browsers. However, I think it should also be mentioned very explicitly that this actually introduces a risk in modern browsers and should only be done if one actually wants to support ES3 browsers.
What do you think?
The text was updated successfully, but these errors were encountered:
This file provides an example of
undefined
being passed as an argument to a function:The idea here seems to be to make sure
undefined
is really undefined by not passing it into the actual call. However, I believe this is no longer necessary in ES5+ compliant browsers.These days, it's actually safer not to do it as it introduces a way for a developer to introduce a local variable named
undefined
by accidentally calling the function with too many arguments. MDN seems to advise against that and personally, I agree.Later in the same script, there's a comment saying:
I understand that the fact the template still uses this practice is a conscious decision based on the team's belief in continuing to do it to cater for pre-ES5 browsers. However, I think it should also be mentioned very explicitly that this actually introduces a risk in modern browsers and should only be done if one actually wants to support ES3 browsers.
What do you think?
The text was updated successfully, but these errors were encountered: