obj = {key:value}
let obj_ex1 = {1, 2} //expected output Error
let obj_ex2 = {
name: "TaeJoon",
30: "my age",
first_name:["p","a","r","k"],
func: function(value){
return value
}
}
//function접근방법
obj_ex2.func(value);
let myPlants = [
{
type: "flowers",
list: [
"rose",
"tulip",
"dandelion"
]
},
{
type: "trees",
list: [
"fir",
"pine",
"birch"
],
30: "my age"
}
];
myPlants[0].type //dot notation
myPlants[0]['type'] //bracket notation
//both of expected output: flowers
myPlants[0].list[1] //dot notation
myPlants[0]['list'][1] //bracket notation
//both of expected output: tulip
ex)
myPlants[1].30 //dot notation expected output: Error
myPlants[1][30] || myPlants[1]['30']
//bracket notation expected output: "my age"