if (nxt_fast_path(ov != NULL)) {
nxt_lvlhsh_init(&ov->object.hash);
- nxt_lvlhsh_init(&ov->object.shared_hash);
+
+ if (type == NJS_STRING) {
+ ov->object.shared_hash = vm->shared->string_instance_hash;
+
+ } else {
+ nxt_lvlhsh_init(&ov->object.shared_hash);
+ }
+
ov->object.type = njs_object_value_type(type);
ov->object.shared = 0;
ov->object.extensible = 1;
return NXT_ERROR;
}
- object->shared_hash = vm->shared->string_instance_hash;
-
vm->retval.data.u.object = object;
vm->retval.type = NJS_OBJECT_STRING;
vm->retval.data.truth = 1;
{ nxt_string("new String(123)"),
nxt_string("123") },
+ { nxt_string("Object('123').length"),
+ nxt_string("3") },
+
{ nxt_string("new String(123).length"),
nxt_string("3") },