js foreach key value
Object.keys(obj).forEach(function (key) { // do something with obj[key] });
js foreach key value
Object.keys(obj).forEach(function (key) { // do something with obj[key] });
javascript map foreach
const myArray = ['Sam', 'Alice', 'Nick', 'Matt']; // Appends text to each element of the array const newArray = myArray.map(name => { return 'My name is ' + name; }); console.log(newArray); // ['My name is Sam', 'My Name is Alice', ...] // Appends the index of each element with it's value const anotherArray = myArray.map((value, index) => index + ": " + value); console.log(anotherArray); // ['0: Sam', '1: Alice', '2: Nick', ...] // Starting array is unchanged console.log(myArray); // ['Sam', 'Alice', 'Nick', 'Matt']
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us