JavaScript Special Operators

Source: Internet
Author: User

In operator
The in operator requires that its left operand be a string, or can be converted to a string, to the right of the operation dozens of an object or an array. Returns true if the value to the left of the operator is a property name for the right object, otherwise returns false.
eg


instanceof operator
The instanceof operator requires that the operand to the left is an object, and the operand on the right is the name of the object class, if the object to the left of the operator is
Returns true for an instance of the right class, otherwise false.
eg



typeof operator
typeof is a unary operator that can be any type before it is placed in an operand. Its return value is a string that describes the type of operand that is typically typeof returned as follows: number,string,boolean,object,function,undefined
typeof can enclose the operands, similar to the use of a function
eg

The limitation of ps:typeof is that for special objects such as Array,null, the use of TypeOf returns is object, but not detailed to distinguish, this time will use instanceof, but the premise must be able to use the instanceof operator

Delete operator
The delete operator is a unary operator that deletes the properties, array elements, or variables of the object specified by the operand. If the deletion succeeds, returns true if the operand cannot be deleted, and false is returned. And not all properties and variables can be deleted, some internal core properties and client properties cannot be deleted, and user-defined variables declared with the Var statement cannot be deleted. If the operand used by delete is a nonexistent property, it will also return true (it is surprising that the ECMAScript standard specifies that it will also return true when the operand of the delete operation is not a property, an array, or a variable)
eg


void operator
Void is a unary operator that can appear before any type of operand. The use of this operator is special, it always discards the number of operands
Value, and then returns undefined. This operator is commonly used in the client's Javascript:url, where the value of an expression can be evaluated, and the browser does not display this value. Another use of void is to generate undefined values specifically
eg


comma operator
The comma operator is very simple, it evaluates the left argument first, evaluates the argument to its right, and then returns the value of the right argument.
eg

The two types of notation are equivalent

JavaScript Special Operators

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.