const arr = []
for(let i=0 ; i<=5 ; i++ );{
arr.push(i)
}
console.log(arr)
Can anyone explain me this scenario ?
I just rewrite above code. In for loop i will be increase from 0 to 5, when i reaches to 6, it will be return through i<=5. and push 6 to arr. that's it.
const arr = []
for(var i=0 ; i<=5 ; i++){} // i will be from 0 to 6.
{
arr.push(i)
}
console.log(arr) // [6]
The semicolon between round bracket and curly stops the statement.
You can do the following: