JSON vs Object Literals
Video
JavaScript Notes
JavaScript
//JavaScript
//Object literals (.js)
let obj1 = {
'prop1': "string",
"prop2": 'string',
prop3: 123,
prop4: ['array', "value", obj2, 123],
prop5: function(){
console.log('message');
},
prop6: null,
prop7: true
}
let obj2 = function(){
console.log('obj2');
}
//JSON file (.json)
{
"prop1": "string",
"prop2": "string",
"prop3": 123,
"prop4": ["array", "value", "obj2", 123],
"prop5": {
"p1": "v1",
"p2": "v2",
"p3": false,
"p4": 654,
"p5": null
},
"prop6": null,
"prop7": true
}
Feedback
Submit and view feedback