JS::ToString

This article covers features introduced in SpiderMonkey 31

Convert any JavaScript value to a string.

Syntax

#include "js/Conversions.h" // as of SpiderMonkey 38; previously in jsapi.h
JSString*
JS::ToString(JSContext *cx, JS::HandleValue v)
Name Type Description
cx JSContext * The context in which to perform the conversion. Requires request. In a JS_THREADSAFE build, the caller must be in a request on this JSContext.
v JS::HandleValue The value to convert.

Description

JS::ToString returns a string representation of a JavaScript value.

If v.isString() is true, it calls v.toString(). Otherwise, it converts the value to string.

On success, JS::ToString returns a JSString instance. On error or exception, it returns nullptr.

See Also

Document Tags and Contributors

 Contributors to this page: Waldo, Hub, kscarfone, arai
 Last updated by: Waldo,