void操作符

void操作符也许常常被用到,但是可能大家对其了解不多。

void操作符是一个一元运算符,求值结果总是undefined,但是其求值过程可能会产生副作用:

E.g

var temp=1;
var b=void(temp=2);
alert(temp)
// result:2
alert(b);// result:undefined

参考:

ecma 262 edition 5.1----11.4.2 The void Operator

原文地址:https://www.cnblogs.com/argb/p/2115362.html