Objetos javascript
const objectName = {
member1Name: member1Value,
member2Name: member2Value,
member3Name: member3Value
};
Itchy Iguana
const objectName = {
member1Name: member1Value,
member2Name: member2Value,
member3Name: member3Value
};
var student = { // object name
firstName:"Jane", // list of properties and values
lastName:"Doe",
age:18,
height:170,
fullName : function() { // object function
return this.firstName + " " + this.lastName;
}
};
const someObj = {
propName: "John"
};
function propPrefix(str) {
const s = "prop";
return s + str;
}
const someProp = propPrefix("Name");
console.log(someObj[someProp]);
const person = {
name: 'Anthony',
age: 32,
city: 'Los Angeles',
occupation: 'Software Developer',
skills: ['React','JavaScript','HTML','CSS']
}
//Use Template Literal to also log a message to the console
const message = `Hi, I'm ${person.name}. I am ${person.age} years old. I live in ${person.city}. I am a ${person.occupation}.`;
console.log(message);
const person = {
name: 'Nick'
};
person.name = 'John' // this will work ! person variable is not completely reassigned, but mutated
console.log(person.name) // "John"
person = "Sandra" // raises an error, because reassignment is not allowed with const declared variables
var object = {'key':'value','the value can be anything',[1,null,'Dr.Hippo']};