Analysis of in operator usage in javascript
- 2020-06-03 05:46:46
- OfStack
This article illustrates the use of the in operator in javascript. Share to everybody for everybody reference. The specific analysis is as follows:
The in operator wants its left operand to be a string or to be converted to a string, and its right operand to be an object. If the right object has a property name called the left operation value, the expression returns true:
var point = {x:1,y:1};
"x" in point //true
"z" in point //false
"toString" in point //true
var ary = [1,2,3];
"0" in ary; //true . ary Contains the index 0("0" Back into 0) ;
1 in ary; //true,ary Contains the index 1
3 in ary; //false
Hopefully, this article has been helpful in your javascript programming.