Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

1.

What is use of hasOwnProperty method

Answer»

What is USE of hasOwnProperty method
It will return true if the property was SET on an actual object rather than INHERITED.

2.

Point where JSON is better then XML

Answer»

Point where JSON is better then XML
Below are the 6 main points why JSON is better then XML
(1)JSON is much is FASTER and lighter than XML as on the wire data format in JSON
(2)JSON objects are typed on another place XML data is typeless
(3)Different JSON types are
(i) Number
(II) Array
(iii)Boolean
(iv) STRING
(4)XML data are always string
(5)Data is readily available as JSON object is in your JavaScript
(6)Fetching values is as SIMPLE as reading from an object PROPERTY in your JavaScript code

3.

Different JSON data types

Answer»

Different JSON data types
Below are the different JSON data types
(1)Numbers:- Example are Integer, float or Double
(2)String:- Example of string which is of Unicode characters, must be rapped into double QUOTES
(3)Boolean:- Example of this is True or false
(4)Array:- Example of Array which is ordered list of 0 or more values
(5)Objects:- Example for objects is An unordered COLLECTION key/ value pairs
(6)Null:- Example for Null is An Empty value

4.

Code to convert nested JSON to simple JSON format with JavaScript?

Answer»

Code to CONVERT nested JSON to simple JSON format with JavaScript?
There are certain situation where we have data variety or structure of data is different due to that we will SOMETIME get complex data. And some TIME we need to re-write code to get data. If we can convert that in to simple JSON would be better BASED on the situation.
Below is the example of Nested JSON:-


Nested JSON Object

And below is the output for simple JSON object:-



Nested JSON Output

And below is the code to handle the CONVERSION nested JSON to simple JSON

Nested JSON Code

5.

Use of JSON.parse function in JSON

Answer»

Use of JSON.parse FUNCTION in JSON
Below is the simplest example for using JSON.parse
var myJSONvar = '{"name":"ADAM", "AGE":21, "city":"Gurgaon"}';
var myObjparse = JSON.parse(myJSON);
document.getElementById("Jsondemo").innerHTML = myObjparse.name;