Tuesday, 15 August 2017

JSON Object VS JavaScript Object With Syntax - W3tricks

JSON Object VS JavaScript Object


  • JSON is text-based and indepedent data-exchange.
  • javascript is not pure text-based, it is also value-based.
  • JSON and javascript both also provide a way to define/describe data,
  • but the syntax is very specific to JavaScript.

JSON

  • JSON doesn't define any syntax for functions.
  • In JSON cannot assign a function as a value.
  • JSON keys are not literals(String). They are identifier names.

JSON - Syntax

  • var student = {"name":"Bob","city":"new york","number":1234567890};
  • console.log(student);

Output

javascript - Syntax

  • var student = {name:"Bob",city:"new york",number:1234567890};
  • console.log(student);

OR

  • var student = {name:'Bob',city:'new york',number:1234567890};
  • console.log(student);

Output


0 comments:

Post a Comment