mirror of https://github.com/svaarala/duktape.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
997 B
29 lines
997 B
name: duk_is_primitive
|
|
|
|
proto: |
|
|
duk_bool_t duk_is_primitive(duk_context *ctx, duk_idx_t idx);
|
|
|
|
stack: |
|
|
[ ... val! ... ]
|
|
|
|
summary: |
|
|
<p>Returns 1 if value at <code>idx</code> is a primitive type, as defined in
|
|
<a href="http://www.ecma-international.org/ecma-262/5.1/#sec-9.1">ToPrimitive</a>,
|
|
otherwise returns 0. If <code>idx</code> is invalid, also returns 0.</p>
|
|
|
|
<p>Any standard type other than an object is a primitive type. The custom
|
|
plain pointer type is also considered a primitive type. However, the custom
|
|
plain buffer type (which behaves like an Uint8Array object in most situations) and
|
|
lightfunc type (which behaves like a Function object in most situations) are not
|
|
considered a primitive type. This matches the behavior of <code>duk_to_primitive()</code>
|
|
which (usually) coerces e.g. a plain buffer to the string <code>[object Uint8Array]</code>.</p>
|
|
|
|
example: |
|
|
if (duk_is_primitive(ctx, -3)) {
|
|
/* ... */
|
|
}
|
|
|
|
tags:
|
|
- stack
|
|
|
|
introduced: 1.0.0
|
|
|