Use JS friends for the in is not unfamiliar with it, the following examples for you to introduce their specific use of the method
for (var i=0;i<len;i++) Such usage can generally be replaced with for. For example, the: code is as follows: var a = ["A", "B", "C"]; for (Var el in a) { alert (a[el)); } This is the name of the poor name There are elements, of course above This example can be used code as follows: for (var i=0,len=a.length;i<len;i++) { alert (a[i)); } This is a way of looping through the list, but sometimes this is not necessarily the way it works. For example, the: code is as follows: var a = {"A": 1, "second": 2, "third":3}; this time can only use for to the poor lift. Whether an object can be used for in-exhaustive, we can judge by the propertyIsEnumerable property, stating the following: propertyisenumerable properties return Boolean Value that indicates whether the specified property is part of an object and whether the property is enumerable. Copy code code as follows: Object.propertyisenumerable (proname) parameter object required option. An object. proname required options. A string value for a property name. Description If Proname exists in object and you can use a for ... The propertyIsEnumerable property returns True if the in loop is a poor lift. If object does not have the specified property or the specified property is not enumerable, then the propertyIsEnumerable property returns False. Typically, predefined properties are not enumerable, and user-defined attributes can always be enumerated. The propertyisenumerable attribute does not consider objects in the prototype chain.