Explanation on the usage of for in statement in js_javascript skills
for(variable in object)
statement
variable is a var statement that declares a variable, an element of an array or an attribute of an object
Inside the loop body, a property name of the object is assigned to the variable as a string.
Note: Some properties of the object are marked as read-only, permanent (non-deletable) or non-enumerable in the same way. These properties cannot be enumerated using for/in loops. Although all user-defined properties are enumerable, many internal properties, including all internal methods, are not enumerable. In addition, objects can inherit properties from other objects, and those inherited user-defined properties can be enumerated using a for/in loop.
Usage likefor(var i=0;i For example: Whether an object can be exhaustively for in can be judged by the propertyIsEnumerable attribute. The description is as follows: Whether object.propertyIsEnumerable(propname) can see the property through for/in loop Description: You can use the for/in statement to traverse the "enumerable" properties of an object, but not all properties of an object are enumerable. Properties added to the object through JavaScript code are enumerable, and internal Predefined properties of objects (such as methods) are usually not enumerable. The propertyIsEnumerable() method does not check the prototype chain, which means it only applies to local properties of the object and cannot detect the enumerability of inherited properties
var a = ["a","b","c"];
for(var el in a){
alert(a[el]);
}
This is to enumerate all the elements in a. Of course, the above example can be used
for(var i=0,len=a.length;i
}
This method is used to list in a loop, but sometimes this method may not work.
For example:
var a = {"first":1,"second":2,"third":3};
At this time, you can only use for in to exhaust the list.
propname is a string containing the name of the object attribute
If the object has a non-inherited property named propname, and the property is enumerable (that is, it can be enumerated using a for/in loop), return true
var o=new Object();
o.x=3.14;
o.propertyIsEnumerable("x");//true
o.propertyIsEnumerable("y");//false have not the property
o.propertyIsEnumerable("toString");//false inherited
Object.prototype.propertyIsEnumerable("toString");//false nonenumerable

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Kernelsecuritycheckfailure (kernel check failure) is a relatively common type of stop code. However, no matter what the reason is, the blue screen error causes many users to be very distressed. Let this site carefully introduce 17 types to users. Solution. 17 solutions to kernel_security_check_failure blue screen Method 1: Remove all external devices When any external device you are using is incompatible with your version of Windows, the Kernelsecuritycheckfailure blue screen error may occur. To do this, you need to unplug all external devices before trying to restart your computer.

Face detection and recognition technology is already a relatively mature and widely used technology. Currently, the most widely used Internet application language is JS. Implementing face detection and recognition on the Web front-end has advantages and disadvantages compared to back-end face recognition. Advantages include reducing network interaction and real-time recognition, which greatly shortens user waiting time and improves user experience; disadvantages include: being limited by model size, the accuracy is also limited. How to use js to implement face detection on the web? In order to implement face recognition on the Web, you need to be familiar with related programming languages and technologies, such as JavaScript, HTML, CSS, WebRTC, etc. At the same time, you also need to master relevant computer vision and artificial intelligence technologies. It is worth noting that due to the design of the Web side

Classification and Usage Analysis of JSP Comments JSP comments are divided into two types: single-line comments: ending with, only a single line of code can be commented. Multi-line comments: starting with /* and ending with */, you can comment multiple lines of code. Single-line comment example Multi-line comment example/**This is a multi-line comment*Can comment on multiple lines of code*/Usage of JSP comments JSP comments can be used to comment JSP code to make it easier to read

WPS is a commonly used office software suite, and the WPS table function is widely used for data processing and calculations. In the WPS table, there is a very useful function, the DATEDIF function, which is used to calculate the time difference between two dates. The DATEDIF function is the abbreviation of the English word DateDifference. Its syntax is as follows: DATEDIF(start_date,end_date,unit) where start_date represents the starting date.

How to use the exit function in C language requires specific code examples. In C language, we often need to terminate the execution of the program early in the program, or exit the program under certain conditions. C language provides the exit() function to implement this function. This article will introduce the usage of exit() function and provide corresponding code examples. The exit() function is a standard library function in C language and is included in the header file. Its function is to terminate the execution of the program, and can take an integer

Can Win10 skype be uninstalled? This is a question that many users want to know, because many users find that this application is included in the default program on their computers, and they are worried that deleting it will affect the operation of the system. Let this website help users Let’s take a closer look at how to uninstall Skype for Business in Win10. How to uninstall Skype for Business in Win10 1. Click the Windows icon on the computer desktop, and then click the settings icon to enter. 2. Click "Apply". 3. Enter "Skype" in the search box and click to select the found result. 4. Click "Uninstall". 5

The ISNULL() function in MySQL is a function used to determine whether a specified expression or column is NULL. It returns a Boolean value, 1 if the expression is NULL, 0 otherwise. The ISNULL() function can be used in the SELECT statement or for conditional judgment in the WHERE clause. 1. The basic syntax of the ISNULL() function: ISNULL(expression) where expression is the expression to determine whether it is NULL or

How to use Apple shortcut commands With the continuous development of technology, mobile phones have become an indispensable part of people's lives. Among many mobile phone brands, Apple mobile phones have always been loved by users for their stable systems and powerful functions. Among them, the Apple shortcut command function makes users’ mobile phone experience more convenient and efficient. Apple Shortcuts is a feature launched by Apple for iOS12 and later versions. It helps users simplify their mobile phone operations by creating and executing custom commands to achieve more efficient work and
