In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how to use the javascript special operator". Friends who are interested may wish to take a look. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn how to use the javascript special operator.
Javascript special operators are: 1, the comma operator ",", which returns the value of the rightmost Operand; 2, the "delete" operator, which deletes a property of an object; 3, the "in" operator; 4, the "instanceof" operator; 5, the "typeof" operator; 6, the "void" operator.
The operating environment of this tutorial: windows7 system, javascript1.8.5 version, Dell G3 computer.
Comma operator: returns the value of the rightmost Operand
The comma operator in javascript is a binary operator that executes the Operand on the left, then the Operand on the right, and finally returns the value of the Operand on the right.
A = b = 1 ~ c = 2 console.log (a); / return 1console.log (b); / / return 1console.log (c); / / return 2var x = (1, 2, 3); alert (x); / / 3
II. Delete operator: deletes an attribute of an object
The delete operator removes an attribute from an object or an element from an array.
Var obj = {x: 1, y: 2}; obj.x; / / 1delete obj.x;obj.x; / / undefined
Note:
1. Delete cannot delete the attributes of objects labeled false by configurable:
Var obj = {}; Object.defineProperty (obj,'x cards, {configurable: false, value: 1}); delete obj.x; / / falseobj.x; / / 1
2. Cannot be used to delete constants
Var a = 1 * * delete a; / / false
3. Cannot be used to delete function declarations
Function fun () {} delete fun; / / false
3. "in" operator: determines whether an attribute belongs to an object
The in operator requires that the Operand on the left is a string, and the Operand on the right is an array or object. If the value on the left is a property name of the object on the right, it returns true, otherwise it returns false.
Var obj = {name: 'person', age: 20};' name' in obj; / / true
4. Instanceof operator
The instanceof operator requires that the Operand on the left is an object, and the Operand on the right is the name of the object class, if the object on the left of the operator is
An instance of the class on the right returns true, otherwise it returns false.
Var d = new Date (); d instanceof Date; / / return trued instanceof Object; / / return trued instanceof Number; / / return false
5. Typeof operator
Typeof is a unary operator that precedes an Operand, which can be of any type. Its return value is a string that describes the type of Operand usually returned by typeof as follows: number,string,boolean,object,function,undefined
Typeof can enclose operands, similar to the use of a function
Var today=new Date (); typeof myFun / / return objecttypeof shape / / return stringtypeof size / / return number
6. Void operator
Void is a unary operator that can precede any type of Operand. This operator has a special purpose. It always discards operands.
Value and then return undefined. This operator is commonly used in javascript:URL on the client side, where you can evaluate the value of an expression that the browser does not display. Another use of void is to specifically generate undefined values
Var a = b = c = 2; d = void (a-= (b * = (c + = 5); console.log (a); / return-12console.log (b); / / return 14console.log (c); / / return 7console.log (d); / / return undefined here. I believe you have a better understanding of "how to use the javascript special operator". You might as well do it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.