JSON, Math, BigInt & Date
Prev: String, RegExp & Intl | Up: builtins | Next: tutorials
Rel: String, RegExp & Intl, Fetch & Networking
Ref: MDN Web Docs — JSON
Tags: #public #web #javascript #builtins
Contents
JSON & structuredClone()
JSON.stringify(val, replacer, space)/JSON.parse(str, reviver)serialize plain JSON data.structuredClone(obj)performs a native deep copy that preservesDate,Map,Set,RegExp,TypedArray, and circular references.
const original = { created: new Date(), tags: new Set(["js", "web"]) };
const copy = structuredClone(original);
Math & BigInt
JavaScript Number is IEEE 754 double-precision (exact integers up to Number.MAX_SAFE_INTEGER = 2**53 - 1). Use BigInt (123n) for arbitrary-precision integers.
const exact = 9007199254740993n + 1n; // 9007199254740994n
Date
Store and transmit timestamps in UTC ISO-8601 (new Date().toISOString()) and format for display with Intl.DateTimeFormat.
Linked from
- tuts/databases/mongodb
- tuts/databases/mongodb/bson_documents_and_schema_design
- tuts/javascript/builtins
- tuts/javascript/builtins/JSON
- tuts/javascript/builtins/JSON/parse
- tuts/javascript/builtins/JSON/stringify
- tuts/javascript/builtins/json_math_and_date
- tuts/javascript/builtins/Math
- tuts/javascript/builtins/Math/floor
- tuts/javascript/builtins/Math/hypot
- tuts/javascript/builtins/Math/min
- tuts/javascript/builtins/Math/random
- tuts/javascript/builtins/string_regexp_and_intl
- tuts/programming/data_and_types/binary_numbers_and_encodings
- tuts/web/apis
- tuts/web/apis/storage_and_state
Related notes
- tuts/javascript/builtins Linked here; links to this page; shared tags: #builtins, #javascript, #web
- tuts/javascript/builtins/string_regexp_and_intl Linked here; links to this page; shared tags: #builtins, #javascript, #web
- tuts/javascript/builtins/JSON links to this page; shared tags: #builtins, #javascript, #web
- tuts/javascript/builtins/JSON/parse links to this page; shared tags: #builtins, #javascript, #web
- tuts/javascript/builtins/JSON/stringify links to this page; shared tags: #builtins, #javascript, #web
- tuts/javascript/builtins/Math links to this page; shared tags: #builtins, #javascript, #web
- tuts/javascript/builtins/Math/floor links to this page; shared tags: #builtins, #javascript, #web
- tuts/javascript/builtins/Math/hypot links to this page; shared tags: #builtins, #javascript, #web
- tuts/javascript/builtins/Math/min links to this page; shared tags: #builtins, #javascript, #web
- tuts/javascript/builtins/Math/random links to this page; shared tags: #builtins, #javascript, #web