njs_object_t *object;
const njs_value_t *value;
- type = NJS_OBJECT;
value = njs_arg(args, nargs, 1);
+ type = value->type;
if (njs_is_null_or_void(value)) {
return NXT_ERROR;
}
+ type = NJS_OBJECT;
+
} else {
if (njs_is_object(value)) {
} else if (njs_is_primitive(value)) {
/* value->type is the same as prototype offset. */
- object = njs_object_value_alloc(vm, value, value->type);
+ object = njs_object_value_alloc(vm, value, type);
if (nxt_slow_path(object == NULL)) {
return NXT_ERROR;
}
- type = njs_object_value_type(value->type);
+ type = njs_object_value_type(type);
} else {
njs_type_error(vm, "unexpected constructor argument:%s",
- njs_type_string(value->type));
+ njs_type_string(type));
return NXT_ERROR;
}
{ nxt_string("var o = {}; o === new Object(o)"),
nxt_string("true") },
+ { nxt_string("var o = Object([]); Object.prototype.toString.call(o)"),
+ nxt_string("[object Array]") },
+
{ nxt_string("Object.name"),
nxt_string("Object") },