JavaScript | JavaScript JSON | Question 9

Last Updated :
Discuss
Comments

What will the following code log?

JavaScript
const json = '[{"id":1},{"id":2}]';
console.log(JSON.parse(json)[0].id);


Error

undefined

1

null

Share your thoughts in the comments