JSON.parse() Method

The JSON.parse() method is a JavaScript method that converts a JSON string into a JavaScript object.

Syntax:

JSON.parse( string, function )

Example: Here is the basic example of JSON.parse() method.

Javascript




let str1 = '{"name": "Aman", "age": 21, "city": "Noida"}';
  
let result = JSON.parse(str1);
  
console.log(result.name);
console.log(result.age);
console.log(result.city);


Output

Aman
21
Noida

JavaScript ES5 (JS 2009)

JavaScript 2009 (ES5) refers to the fifth edition of the ECMAScript language specification, standardized in 2009. It introduced several features, like strict mode, new methods, JSON support, and improved syntax for better programming practices and compatibility across browsers.

ECMAScript 5 (ES5) introduced several significant features to JavaScript, enhancing the language’s capabilities.

Name

Description

use strict

Enforces stricter parsing and error handling in JavaScript code.

String.trim()

Removes whitespace from the beginning and end.

Multiline strings

Use backslashes at the end of each line to continue.

Array.isArray()

Check if an object is an array.

Array.forEach()

Iterates over array elements, applying a provided function.

Array.map()

Transforms each array element using a provided function.

Array.filter()

Creates a new array with elements passing a test.

Array.reduce()

Combines an array of elements to produce a single result.

Array.reduceRight()

Combines array elements from right to left.

Array.every()

Checks if all elements satisfy a given condition.

Array.some()

Checks if any element satisfies a given condition.

Array.indexOf()

Returns the index of a specified element.

Array.lastIndexOf()

Returns the last index of a specified element.

JSON.parse()

Converts JSON string to JavaScript object.

JSON.stringify()

Converts JavaScript object to JSON formatted string.

Date.now()

Returns the current timestamp in milliseconds since 1970.

Date toISOString()

Converts date to ISO 8601 format string.

Date toJSON()

Converts date to JSON-formatted string (ISO 8601).

Property Getters and Setters

Control object property access and modification behavior.

Object.defineProperty()

Defines or modifies a property’s attributes on an object.

Object.defineProperties()

Defines or modifies multiple properties’ attributes on an object.

Object.getOwnPropertyDescriptor()

Gets attributes of a property from an object.

Object.keys()

Returns an array of enumerable property names in object.

Object.getOwnPropertyNames()

Returns an array of all property names in object.

Object.preventExtensions()

Prevents adding new properties to an object.

Object.isExtensible()

Checks if new properties can be added.

Object.seal()

Prevents new properties and makes existing non-configurable.

Object.isSealed()

Checks if object properties are non-configurable and sealed.

Object.freeze()

Prevents adding, modifying, and makes properties non-writable.

Object.isFrozen()

Checks if object properties are non-writable, non-configurable, and frozen.

Here is the explanation of above-mentioned topic

Similar Reads

Method 1: use strict

The use strict enforces strict mode in JavaScript, catching errors and promoting better coding practices. It’s used at the beginning of scripts or functions....

Method 2: String.trim() Method

...

Method 3: Multiline Strings

JavaScript String trim() method is used to remove the white spaces from both ends of the given string....

Method 4: Array Methods (Array.isArray(), Array.map(), Array.filter(), and Array.reduce() Methods)

...

Method 5: JSON.parse() Method

In ES5, multiline strings can be created using backslashes at the end of each line to continue, combined with + for concatenation, to form a single string across lines....

Method 6: JSON.stringify() Method

...

Date Methods (Date.now(),Date toISOString() and Date toJSON() Methods)

The Array.isArray() method checks if a value is an array or not and returns true or false. The Array.map() method transforms each element in an array using a provided function, returning a new array. Array.filter() method creates a new array with elements that satisfy a condition set by a function. The Array.reduce() method reduces array to a single value by executing a function with accumulator....

Method 7: Property Getters and Setters

...

Method 8: New Object Property Methods

The JSON.parse() method is a JavaScript method that converts a JSON string into a JavaScript object....