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 训练狗狗憋尿
2 狗狗追踪训练
3 狗狗训练要多少钱
5 深圳狗狗训练
6 训练狗狗唤回
7 狗狗叫怎么训练
8 狗狗训练班
10 狗狗社会化训练
11 狗狗叫回训练
12 广州狗狗训练学校
13 狗狗训练躺下
14 狗狗随行训练
15 训练狗狗巡回
16 狗狗要怎么训练
17 狗狗喂食训练
18 训练狗狗躺下