for key value in object javascript
for (const [key, value] of Object.entries(object1)) {
console.log(`${key}: ${value}`);
}
for key value in object javascript
for (const [key, value] of Object.entries(object1)) {
console.log(`${key}: ${value}`);
}
variable key name js
//You need to make the object first, then use [] to set it.
var key = "happyCount";
var obj = {};
obj[key] = someValueArray;
myArray.push(obj);
javascript create object key from variable
//For ES6 and Babel
{
[yourKeyVariable]: "yourValue",
}
// ES5 Alternative
// Create the object first, then use [] to set your variable as a key
var yourObject = {};
yourObject[yourKeyVariable] = "yourValue";
js variable for key obj
{
[yourKeyVariable]: someValueArray,
}
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