JavaScript :: for…循环中
在 为...在 循环通过一个对象的属性用于循环。由于我们尚未讨论对象,因此您可能不喜欢此循环。但是一旦了解了对象在JavaScript中的行为,您就会发现此循环非常有用。
语法
for..in循环的语法是-
for (variablename in object) {
statement or block to execute
}在每次迭代中,将来自对象的一个属性 分配给 变量名, 并且此循环一直进行到对象的所有属性用尽为止。
例子
尝试以下示例实现“for-in”循环。它打印Web浏览器的 Navigator 对象。
Set the variable to different object and then try...
输出
Navigator Object Properties serviceWorker webkitPersistentStorage webkitTemporaryStorage geolocation doNotTrack onLine languages language userAgent product platform appVersion appName appCodeName hardwareConcurrency maxTouchPoints vendorSub vendor productSub cookieEnabled mimeTypes plugins javaEnabled getStorageUpdates getGamepads webkitGetUserMedia vibrate getBattery sendBeacon registerProtocolHandler unregisterProtocolHandler Exiting from the loop! Set the variable to different object and then try...
热门推荐
10 五一公司放假祝福语简短
11 追星女孩的祝福语简短
12 给长辈端午祝福语 简短
13 生日祝福语有诗意简短
14 团圆日祝福语简短
15 中秋商务祝福语简短最新
16 温暖文艺简短祝福语短句
17 男孩上学祝福语简短的
18 入住酒店文案祝福语简短