Author: Saim Khalid

  • 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…

  • Loop Control

    JavaScript Loop Control JavaScript provides full control to handle loops and switch statements. There may be a situation when you need to come out of a loop without reaching its bottom. There may also be a situation when you want to skip a part of your code block and start the next iteration of the…

  • 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…

  • 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…

  • While Loops

    A while statement in JavaScript creates a loop that executes a block of code repeatedly, as long as the specified condition is true. The condition is evaluated before the execution of the block of code. While writing a program, you may encounter a situation where you need to perform an action over and over again. In such situations,…

  • if else Statement

    The JavaScript if…else statement executes a block of code when the specified condition is true. When the condition is false the else block will be executed. The if-else statements can be used to control the flow of execution of a program based on different conditions. While writing a program, there may be a situation when you need to adopt…

  • Operator Precedence

    In JavaScript, operator precedence ensures the priority of the operators to be executed when a single expression contains multiple operators. So, whatever expressions have higher priority, the compiler executes it first over other operators and then executes the operators with the lower precedence. Whenever you write any JavaScript expression with only 1 or 2 operators, you can…

  • Exponentiation Operator

    Exponentiation Operator The exponentiation operator in JavaScript is represented as **. The exponentiation operator takes two operands and returns the power of the first operand raised to the second. The exponentiation operator can also accept the variables of the BigInt data type as operands. Also, it follows the property of associativity, which means a**b**c and a**(b**c) expressions…

  • Spread Operator

    What is a Spread Operator? The JavaScript spread operator () allows us to spread out elements of an iterable such as an array. The spread operator is represented with three dots (). This is operator is introduced in ES6. The main use cases of the spread operator are to copy array elements, concatenate arrays or objects with…