Undefined is a global property that indicates that no assignment has been defined or defined.
Void is a unary operator that returns undefined no matter what parameters are passed in. The void operator is defined in ECMAScript V1, and undefined is defined in ECMAScript v5. We know that
undefined is not a reserved word for JavaScript, so we can use undefined as the variable name. At this point, the undefined we define
will affect the use of undefined as a judgment place . Look at the following example: tested mainstream browsers ie7-ie11, Opera, Firefox, Safati, Chrome
undefined=123; // IE7, IE8 is 123, the rest: Ie9-ie11, opera, Firefox, Safati, Chrome are undefined alert (void 0); // Ie7-ie11, Opera, Firefox, Safati, Chrome are all undefined
Finally, a summary:
using void 0 instead of undefined is for compatibility and for preventing code from being non-canonical (self-modifying the value of undefined).
The meaning of void 0 in JavaScript and the difference between undefine and void 0