Tech Study

JavaScript for loop

For-loop is used when you want to execute a block of code repeatedly for a particular amount of time.

Let’s consider an example, suppose you want to print “hello world” 5 times, what we will do is write console.log(“hello world”) five times.

Instead what we can do is used a for loop for same the with less effort, here’s how :

for(var i = 0 ; i<4; i++)


console.log(“Hello world\n”);


Output :

Hello world

For…in loop

JavaScript has “for…In” loop.“for In” loop is used to loop over objects or enumerable properties of an object, still confused?

Let’s us see an example that will clear your doubt:

const fruits = {1 : “apple”, 2:“banana”}

let x = “ ”;

for( let i in fruits)


console.log(i + “:” + fruits[i])


Output :

1 : apple

2 : banana

Here, “I” represents the keys of the object and fruits[i] represent respective key values.


This loop can be used over array, maps, sets, objects, strings and more, this loop was introduced in ECMA script 6 (ES6), it is like the simple version of the general for-loop, it iterates through all the iterables present in the iterable.

You will understand easily with a simple example below:

const nums = [2,3,5,5,6]

for(num in nums)




Output :






Java Final keyword

Introduction : java final keyword The final keyword present in Java programming language is generally used for restricting the user. …

Read more

C++ Memory Management: new and delete

C++ Memory Management We know that arrays store contiguous and the same type of memory blocks, so memory is allocated …

Read more