We know that to convert a function declaration expression into a function expression in js, you only need to add operators such as +,-,=,~ or ! or () in front of the function declaration.
In addition, you can also use the void operator for conversion. Here is a simple example:
Js code
void function(){console.log(1)}(); //1
void function(g) {console.log(g)}(this); //window
void is also commonly used in two places in project development:
1. Get the real undefined through void 0; 2. Change a The href attribute of the element is set to javascript:void 0; to prevent page jumps.