My Blog

My WordPress Blog

My Blog

My WordPress Blog

3. Control Flow

For…of Loop

JavaScript for…of Loop The for…of loop in JavaScript is used to traverse elements of the iterable object. In each iteration, it gives an element of the iterable object. Iterable objects include arrays, strings, maps, sets, and generators. The JavaScript for…of loop is a much more efficient way to iterate over iterables than using a for…in loop. The for…of loop iterates over the property […]

User Defined Iterators

In JavaScript, an iterable is an object which has Symbol.iterator() method in the object prototype. Some examples of iterable are array, set, map, string, etc. The Symbol.iterator() method returns an object containing the next() method is called iterator. Here, the next() method returns the elements of iterable in each call. The next() Method The next() method […]

Switch Case

The JavaScript switch case is a conditional statement is used to execute different blocks of code depending on the value of an expression. The expression is evaluated, and if it matches the value of one of the case labels, the code block associated with that case is executed. If none of the case labels match the value of the […]

Break Statement

The break statement in JavaScript terminates the loop or switch case statement. When you use the break statement with the loop, the control flow jumps out of the loop and continues to execute the other code. The break statement can also be used to jump a labeled statement when used within that labeled statement. It is a useful tool for controlling […]

For…in Loop

The for…in Loop The for…in loop in JavaScript is used to loop through an object’s properties. The JavaScript for…in loop is a variant of the for loop. The for loop can’t be used to traverse through the object properties. So, the for…in loop is introduced to traverse through all object properties. As we have not discussed Objects yet, you may not feel comfortable […]

For Loop

The JavaScript for loop is used to execute a block of code repeteatedly, until a specified condition evaluates to false. It can be used for iteration if the number of iteration is fixed and known. The JavaScript loops are used to execute the particular block of code repeatedly. The ‘for’ loop is the most compact form of […]

Scroll to top