Home > Web Front-end > JS Tutorial > body text

Analysis of usage of in operator in javascript_javascript skills

WBOY
Release: 2016-05-16 16:01:46
Original
1153 people have browsed it

The example in this article describes the usage of in operator in javascript. Share it with everyone for your reference. The specific analysis is as follows:

The

in operator hopes that its left operand is a string or can be converted to a string, and that its right operand is an object; if the right-hand object has an attribute name named the left operand value, then the expression The formula 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含有索引0("0"回转换为0);
1 in ary;  //true,ary含有索引1
3 in ary;  //false
Copy after login

I hope this article will be helpful to everyone’s JavaScript programming design.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!