Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

SpiderMonkey/JSAPI_参考/JS_ValueToString

把一个jsval值 转换成一个 JSString.

 

语法

JSString * JS_ValueToString(JSContext *cx, jsval 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 jsval 转换的jsval值.

描述

JS_ValueToString converts a specified JS value, v, to a JS string. It implements the ToString operator specified in ECMA 262-3 §9. If v is an object, the actual conversion is performed by its JSClass.convert callback, which may call the JavaScript methods v.toString() and/or v.valueOf(). On success, JS_ValueToString returns a pointer to a string. On error or exception, it returns NULL. This happens, for example, if v is an object and v.toString() throws an exception.

The resulting JSString is subject to garbage collection unless you protect it using a local root, an object property, or the JS_AddRoot function.

See Also

MXR ID Search for JS_ValueToString

JS_ConvertArguments, JS_ConvertValue, JS_GetTypeName, JS_TypeOfValue, JS_ValueToBoolean, JS_ValueToFunction, JS_ValueToInt32, JS_ValueToNumber, JS_ValueToObject

文档标签和贡献者

 此页面的贡献者: ziyunfei, kunpeng
 最后编辑者: ziyunfei,