FrontendArk

Master Frontend Interviews

  • Practice
  • Playground
  • Resource
Hard

JSON.stringify II

45mins

Implement a function jsonStringify(value) that converts a JavaScript value into a JSON string.

The function should:

  • Handle objects, arrays, numbers, strings, booleans, and null.
  • Recursively serialize nested objects and arrays.
  • Ignore functions, symbols, and undefined values in objects.
  • Throw an error if circular references are detected.

Examples

jsonStringify({ a: 1, b: [2, 3] }); // '{"a":1,"b":[2,3]}' jsonStringify([1, { x: 2 }]); // '[1,{"x":2}]' jsonStringify({ a: undefined, b: 2 }); // '{"b":2}'

Code Editor

JavaScript Function

00:00
Loading...

Test Cases

No test results yet

Click "Run" to execute tests