Created
August 29, 2022 14:02
-
-
Save syedjafer/f8eca58d5baf089f78feec721b20e627 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const data = [5, 4, 3, 2, 1]; | |
// Usage 1 - | |
data.forEach(val => console.log("Usage 1", val)); | |
// Usage 2 - Mutating(changing the array value inplace) | |
data.forEach((val, index) => { | |
data[index] = val * val; | |
}) | |
console.log("Inplace value changes, ", data); | |
// Functionality check on return value. | |
const result = data.forEach((val) => { | |
val*val; | |
}) | |
console.log("Result of return value is, ", result); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment