You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In JavaScript, there's a distinction between a JavaScript object and a JSON object, although they may seem similar.
JavaScript Object:
constdetail={"name": "Vipin","age": 21};
Here, detail is a JavaScript object. It's defined using object literal notation, denoted by curly braces {}. This object has two properties: "name" with the value "Vipin" and "age" with the value 21. This is a native JavaScript object.
JSON Object:
constdetail='{ "name": "Vipin", "age": 21 }';
Here, detail appears to be a JSON-like string. JSON stands for JavaScript Object Notation, and it's a lightweight data-interchange format. The provided example, however, is a string literal, not a JSON object. It's important to note that JSON is primarily a data format used for exchanging data between a server and a client, and it's a subset of JavaScript object literal notation.
After parsing, parsedDetail becomes a JavaScript object equivalent to { "name": "Vipin", "age": 21 }.
In summary, while JavaScript objects and JSON objects share some similarities, they are not the same. JSON is a text format that is completely language-independent but uses conventions familiar to programmers of the C-family of languages, while JavaScript objects are native data structures in JavaScript itself.
Please update the readme
Javascript Object
const detail = { "name": "Vipin", "age": 21 };
JSON Object
const detail = '{ "name": "Vipin", "age": 21 }';
JSON object is string. After parse they are separated into key/value.
The text was updated successfully, but these errors were encountered: