What is the purpose of the search() method in strings?
Returns an array of matches
Finds the index of the first match
Validates a regular expression pattern
Replaces the first match with a new string
What does the i flag in a regular expression do?
Makes the search case-insensitive
Searches for all matches globally
Stops the search after the first match
Allows the use of groups in the regular expression
Which method converts a JSON string into a JavaScript object?
What will the following code output?
JavaScript
const obj = { name : "Ajay" , age : 25 };
console . log ( JSON . stringify ( obj ));
{ name: "Ajay", age: 25 }
'{"name":"Ajay","age":25}'
Which of the following is a valid JSON structure?
{ "name": "Ajay", "age": 25 }
{ name: "Ajay", age: 25 }
{ name: "Ajay", age: "25" }
What will the following code log?
JavaScript
const obj = { name : "Ajay" , age : 30 };
const json = JSON . stringify ( obj );
console . log ( JSON . parse ( json ). age );
Which method can convert a JavaScript object to a readable JSON string?
What is the key difference between JSON and JavaScript objects?
JSON allows functions as values.
JSON keys can be unquoted.
JSON can include circular references.
JSON requires double-quoted keys and string values.
What will the following code log?
JavaScript
const json = '[{"id":1},{"id":2}]' ;
console . log ( JSON . parse ( json )[ 0 ]. id );
What does JSON.parse() do?
Converts a JavaScript object to a JSON string
Parses a JSON string into a JavaScript object
Formats a JSON string for readability
Master DSA with JavaScript in just 90 days . Explore core DSA concepts, refine your coding skills, and tackle real-world challenges. Take on the Three 90 Challenge —complete 90% of the course in 90 days and earn a 90% refund as a reward for your commitment!
There are 10 questions to complete.
Take a part in the ongoing discussion View All Discussion