implement JSON.parse()
2022年5月1日小于 1 分钟
implement JSON.parse()
Question
This is a follow-up on 21. implement JSON.stringify().
Believe you are already familiar with JSON.parse()
, could you implement your own version?
In case you are not sure about the spec, MDN here might help.
JSON.parse()
support a second parameter reviver
, you can ignore that.
note
Don't use JSON.parse() in your code here It doesn't help you practicing your skills.
Code
/**
* @param {string} str
* @return {object | Array | string | number | boolean | null}
*/
function parse(str) {
// your code here
}