function stringify
stringify(thing: unknown): string

Converts the given parameter into the string equivalent.

If the thing provided has the type of "object", then this function returns JSON.stringify(thing). Otherwise, it will wrap the thing in a String and convert it to it's string representation.

Examples

Example 1

stringify({ foo: "bar" }); // "{ "foo": "bar" }"
stringify([1, 2, 3]); // "[1, 2, 3]"
stringify(1); // "1"

Parameters

thing: unknown

Return Type

string

Usage

import { stringify } from ".";