Hello everyone!!
We are going to learn about for-in loop in javascript. The for (variablename in object) is cross browser technique for iterating the properties of the object which is inside the bracket. Any expression that evaluates to an object may be used as theobjectExpression. variablename is any expression that resolves to a property reference. Objects are collections of properties and every property gets its own standard set of internal properties. Once the iteration starts, the name of the next properties of the object gets assigned to the variablename.It is valid for variablename to resolve to a different reference at each iteration.
For example:-
var a;
for(a in navigator){
document.write(a);
document.write(<br />);
}
Output:-
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
0 Comment(s)