printAll(elements) { for (let i = 0; i < elements.length; i++) { let nextElem = elements[i]; println(nextElement.toString()) } }
function printAll(elements) { for (let nextElement of elements) { println(nextElement.toString()) } } //Try It let collection = [10, 20, 30, 40]; printAll(collection);
for (let nextElement in elements)
for (let nextElement in elements) {
println(nextElement)
}
elements = [Riya, Asha, Chin]
[Riya, Asha, Chin] println(elements) { [Riya, Asha, Chin] for (let nextElement in elements) { println(nextElement) } }
Riya for (let nextElement in elements) { println(nextElement) Riya }
Asha for (let nextElement in elements) { println(nextElement.toString()) Asha }
Chin for (let nextElement in elements) { println(nextElement.toString()) Chin }
[Riya, Asha, Chin] for (let nextElement in elements) { println(nextElement.toString()) }