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.
 
 
 
 
 
 

25 lines
740 B

=proto
duk_bool_t duk_to_boolean(duk_context *ctx, duk_idx_t index);
=stack
[ ... val! ... ] -> [ ... ToBoolean(val)! ... ]
=summary
<p>Replace the value at <code>index</code> with an Ecmascript
<a href="http://www.ecma-international.org/ecma-262/5.1/#sec-9.2">ToBoolean()</a>
coerced value. Returns 1 if the result of the coercion <code>true</code>, 0 otherwise.
If <code>index</code> is invalid, throws an error.</p>
<p>Custom type coercion:</p>
<ul>
<li>Buffer: <code>false</code> for zero-size buffer, <code>true</code> otherwise</li>
<li>Pointer: <code>false</code> for <code>NULL</code> pointer, <code>true</code> otherwise</li>
</ul>
=example
if (duk_to_boolean(ctx, -3)) {
printf("coerced value is true\n");
}
=tags
stack