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...
热门推荐
1 狗狗下楼训练
3 狗狗训练头盔
6 狗狗训练机构
7 训练狗狗步骤
9 狗狗能训练
10 狗狗基本动作训练方法
11 怎么训练狗狗叼饭盆
12 狗狗一岁了还能训练吗
13 训练狗狗的
14 宁波狗狗训练
15 训练狗狗拉屎
16 教狗狗训练
17 狗狗要怎么训练上厕所
18 狗狗靠的训练