Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Javascript Comparing For and While Loop

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 104
    Comment on it

    JavaScript Comparing For and While Loop

    Both the loops are similar in some ways, like both are used for repeated execution of statements as well as execution are done till the condition is true.

    For loop and while loop they differ by the syntax as,

    For loop Syntax :

    for(initialization; Condition ; variable updater) {
    statement 1;
    . 
    .
    .
    statement n;
    }
    

    Here the first variable gets initialized then the condition for the loop is checked and then the variable is updated as incremented or decremented.

    The iterations of statements are done till the condition gets false.

    While loop Syntax: while (Condition) 
    {
    statements; // statements to be executed
    }
    

    In while loop first the condition is checked if only it gets true then only the statements get executed, the iteration of statements execution are done till the condition gets false

 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: