Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • For-in Loop

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 118
    Comment on it

    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)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: