Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions jerry-core/api/jerry.c
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,21 @@ jerry_value_is_undefined (const jerry_value_t value) /**< api value */
return ecma_is_value_undefined (value);
} /* jerry_value_is_undefined */

/**
* Perform instanceof check on the specified two operands.
*
* @return true - if the left hand side is instance of right hand side,
* false - otherwise.
*/
bool
jerry_value_instanceof (const jerry_value_t value, const jerry_value_t proto)
{
jerry_assert_api_available ();

ecma_value_t ret = ecma_op_object_has_instance (ecma_get_object_from_value (proto), value);
return ecma_is_value_true (ret);
}

/**
* Perform the base type of the JavaScript value.
*
Expand Down
1 change: 1 addition & 0 deletions jerry-core/include/jerryscript-core.h
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ bool jerry_value_is_promise (const jerry_value_t value);
bool jerry_value_is_string (const jerry_value_t value);
bool jerry_value_is_symbol (const jerry_value_t value);
bool jerry_value_is_undefined (const jerry_value_t value);
bool jerry_value_instanceof(const jerry_value_t value, const jerry_value_t proto);

/**
* JerryScript API value type information.
Expand Down
1 change: 1 addition & 0 deletions tests/unit-core/test-api.c
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,7 @@ main (void)
val_a = get_property (global_obj_val, "a");
TEST_ASSERT (!jerry_value_is_error (val_a));
TEST_ASSERT (jerry_value_is_object (val_a));
TEST_ASSERT (jerry_value_instanceof (val_a, val_A));

/* Get a.t */
res = get_property (val_a, "t");
Expand Down