0% found this document useful (0 votes)
50 views2 pages

CSS Diff

The document summarizes the key differences between various JavaScript loops and cookies: While and do-while loops - the while loop checks the condition before executing the loop body, whereas the do-while loop executes the body first and then checks the condition. Break and continue - break exits the entire loop, while continue skips the current iteration but allows the loop to continue. For loop and forEach loop - the for loop provides more control and can iterate over any iterable, while forEach is simpler and designed specifically for arrays. Session and persistent cookies - session cookies only last for the browser session and are deleted when the browser closes, while persistent cookies are stored on the user's device until their expiration date

Uploaded by

Om Kawate
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views2 pages

CSS Diff

The document summarizes the key differences between various JavaScript loops and cookies: While and do-while loops - the while loop checks the condition before executing the loop body, whereas the do-while loop executes the body first and then checks the condition. Break and continue - break exits the entire loop, while continue skips the current iteration but allows the loop to continue. For loop and forEach loop - the for loop provides more control and can iterate over any iterable, while forEach is simpler and designed specifically for arrays. Session and persistent cookies - session cookies only last for the browser session and are deleted when the browser closes, while persistent cookies are stored on the user's device until their expiration date

Uploaded by

Om Kawate
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Difference between While and Do-While Loop

Parameter While Do-While


Loop body is executed after the given Loop body is executed, and then the
Definition condition is evaluated. given condition is checked.
Variable Variables are initialized before the Variables may initialize before or within
Initialization execution of the loop. the loop.

Loop Type Entry Control Loop Exit Control Loop.


Semicolon is not used as a part of the Semicolon is used as a part of the
Semicolon syntax. syntax.
while(condition){ do{
Syntax // loop body // loop body
} } while (condition);

Difference between Break and continue

break continue

jumps out of the current loop jumps to the next iteration of the current loop.

skips the remaining skips execution of the remaining statement(s) inside


executions of the current loop the current loop for the current iteration

stops the execution of the stops the execution of the remaining statement(s)
current loop inside the current loop for the current iteration

useful if condition always


useful, if one wants to skip
evaluates to true

Difference between for loop and for each


Parameters For Loop ForEach Loop
Syntax for loop is more flexible forEach loop is simpler
with explicit control over and designed specifically
initialization, condition, for arrays.
and iteration.
Use with arrays for loop can iterate over forEach loop is
arrays and other iterable exclusively designed for
objects. arrays.
Break and Continue for loop supports break forEach loop doesn't
and continue. directly support break or
continue.
Access to Index for loop provides direct forEach loop requires
access to the loop index. workarounds for direct
index access.
Return value for loop can return a forEach loop is mainly for
value. side effects, not for
returning values.
Compatibility for loop is universally forEach loop may not be
supported. available in older
JavaScript environments
but is widely supported in
modern development.

Difference between Session and Persisent Cookies


Session Cookies persistent cookies
It resides in memory for the length of the A persistent cookie is a cookie that is
browser session. assigned an expiration date.

Also known as an in-memory cookie Also known as transient cookie.

Session cookie is automatically deleted It is written to the computer’s hard disk and
when the user exits the browser remains there until the expiration date has
application. been reached; then it’s deleted.

You might also like