Js word form operator

  • 2020-03-30 02:50:48
  • OfStack

1. Void operand and ignore its return value, such as void (1+2),void (0)


<html>
<head>
<meta  http-equiv="content-type" charset="utf-8"/>
<script type="text/javascript">
alert(typeof(void(0)));  //Void (0) evaluates to 0, typeof is: undefined because the return value is ignored
</script>
</head>
<body>
1. with onclick Flexible handling of events; 2.void(expression)<br>
<a href="javascript:void(0);" onclick="location.href='http://www.baidu.com';"> baidu </a>
<a href="javascript:void(location.href='http://www.google.com')"> Google </a>
</body>
</html>

Typeof returns the typeof a variable or value, such as typeof(void 1+2),typeof(void(1+2)).

Because of the operator priority, the operation process of void 1+2 is:

< img SRC = "border = 0 / / files.jb51.net/file_images/article/201405/20140506104849.jpg? 201446104952 ">

3. New is used to create the object real column of the specified class

4. Delete deletes the real column property. There are several points to note about delete:

1. Delete only real column properties, not objects


<html>
<head>
<meta  http-equiv="content-type" charset="utf-8"/>
<script type="text/javascript">
 var parent={};
 var son={age:10};
 parent.son=son;
 alert(parent.son.age);//10
 delete parent.son;
 alert(parent.son);//undefined
 alert(son.age);//10
</script>
</head>
<body> 
</body>
</html>


Related articles: