iIt is a list of pairs with the defined name and it's associated values, enclosed in curly braces ({}).
Object can be defined as :
var colors = {
"darkColors": {
"a" : "red",
"b" : "darkgreen"
},
"lightColor" : "cyan"
}
Now, let us see how to retrieve these object values
If we want to get key value pairs which are been listed in the darkColors
colors.darkColors // { "a" : "red", "b" : "darkgreen" }
If we want to retrieve only specific value then it can be described as :
colors.darkColors.a //red
colors.darkColors.b //darkgreen
colors.lightColor // cyan
Object can be defined as :
var colors = {
"darkColors": {
"a" : "red",
"b" : "darkgreen"
},
"lightColor" : "cyan"
}
Now, let us see how to retrieve these object values
If we want to get key value pairs which are been listed in the darkColors
colors.darkColors // { "a" : "red", "b" : "darkgreen" }
If we want to retrieve only specific value then it can be described as :
colors.darkColors.a //red
colors.darkColors.b //darkgreen
colors.lightColor // cyan
No comments:
Post a Comment