What's the difference between Javascript Object and JSON object

前端 未结 5 1483
南笙
南笙 2020-11-27 02:55

Can anyone tell me the difference between Javascript Object and JSON object with an example?

5条回答
  •  一个人的身影
    2020-11-27 03:24

    Well First of all a JavaScript is just like any other Object in object oriented programming.

    And as RobG said JSON is effectively an object literal in Javascript Notation. But Not exactly. According to a Javascript book it says this is an object defined by using Object Notation:

    var newObject = 
    {     prop1 : true,     
    showMessage : function (msg) {alert(msg)} 
    }; 
    

    According to JSON in JavaScript,

    JSON is a subset of the object literal notation of JavaScript.

    Also you might want to consider taking a look this link

提交回复
热议问题