> ## Documentation Index
> Fetch the complete documentation index at: https://blog.sumathi.dev/llms.txt
> Use this file to discover all available pages before exploring further.

#  Loops in arrays

* .forEach -> to do something for each element
* Array.from(string) -> makes aaray
* for of  -> prints values
* for in -> prints keys

```js theme={null}
let num = [ 3, 23 , 1 , 2 ,6]
for (let i = 0 ; i <num.length;i++){
    console.log(num[i])
}

// For Each loop
num.forEach((element) => {
    console.log(element * element)
})

// Array.from -> used to create array from any other object like html object
// Used in html to go throuh html Collection - . document.getElecmentbyCLassName("input")
let userName = "kalyan";
let arr = Array.from(userName);
console.log(arr)

// for of -> easier way
for (let i of num) {
    console.log(i)
}
// for in
for (let i in num) {
    console.log(i) // giving indexes
    // array is object with keys 0,1,2,3 and values are array elements
    // on object in prints keys
}
```
