We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent e38bff1 commit dbb86fcCopy full SHA for dbb86fc
1 file changed
jsarray.c
@@ -423,9 +423,18 @@ static void Ap_unshift(js_State *J)
423
424
static void Ap_toString(js_State *J)
425
{
426
- int top = js_gettop(J);
427
- js_pop(J, top - 1);
428
- Ap_join(J);
+ if (!js_iscoercible(J, 0))
+ js_typeerror(J, "'this' is not an object");
+ js_getproperty(J, 0, "join");
429
+ if (!js_iscallable(J, -1)) {
430
+ // TODO: call Object.prototype.toString implementation; not via Object.toString JS objects
431
+ js_getglobal(J, "Object");
432
+ js_getproperty(J, -1, "toString");
433
+ js_rot2pop1(J);
434
+ }
435
+ js_copy(J, 0);
436
+ js_call(J, 0);
437
+ js_pop(J, 1);
438
}
439
440
static void Ap_indexOf(js_State *J)
0 commit comments