배열과 비교했을 때 의미를 부여할 수 있음
let user = {
firstName: 'Steve',
lastName: 'Lee',
email: 'steve@codestates.com',
city: 'Seoul'
};
===> lastName 키(Key), 'Lee' 값(value)
let user = {
firstName: 'Steve',
lastName: 'Lee',
email: 'steve@codestates.com',
city: 'Seoul'
};
user.firstName; //'Steve'
user.city; // 'Seoul'
let user = {
firstName: 'Steve',
lastName: 'Lee',
email: 'steve@codestates.com',
city: 'Seoul'
};
user['firstName']; //'Steve'
user['city']; // 'Seoul'
const person = {
name: 'Steve',
age: 16,
};
function getProperty(obj, propertyName) [
let output = getProperty(person, 'name');
console.log(output); // --> 'Steve'
output = getProperty(person, 'age');
console.log(output); // --> 16
let tweet = {
writer: 'stevelee',
createdAt: '2019-09-10',
content: '프리코스 재밌어요!'
};
tweet['category'] = '잡담';
tweet.isPublic = true;
tweet.tags = ['#코드스테이츠', '#프리코스'];
delete tweet.createdAt;
// tweet은 다음과 같아짐
// {writer:'stevelee', content:'프리코스 재밌어요!'}
'content' in tweet; // true
'updatedAt' in tweet; // false