diff --git a/boa_engine/src/builtins/array/mod.rs b/boa_engine/src/builtins/array/mod.rs index 8c3f386707..05b7abc775 100644 --- a/boa_engine/src/builtins/array/mod.rs +++ b/boa_engine/src/builtins/array/mod.rs @@ -1000,8 +1000,8 @@ impl Array { } // b. Let element be ? Get(O, ! ToString(𝔽(k))). let element = o.get(k, context)?; - // c. If element is undefined or null, let next be the empty String; otherwise, let next be ? ToString(element). - let next = if element.is_null_or_undefined() { + // c. If element is undefined, null or the array itself, let next be the empty String; otherwise, let next be ? ToString(element). + let next = if element.is_null_or_undefined() || &element == this { js_string!() } else { element.to_string(context)? diff --git a/boa_engine/src/builtins/array/tests.rs b/boa_engine/src/builtins/array/tests.rs index d14b610e39..595f4d333c 100644 --- a/boa_engine/src/builtins/array/tests.rs +++ b/boa_engine/src/builtins/array/tests.rs @@ -77,6 +77,7 @@ fn join() { TestAction::assert_eq("[].join('.')", js_string!()), TestAction::assert_eq("['a'].join('.')", js_string!("a")), TestAction::assert_eq("['a', 'b', 'c'].join('.')", js_string!("a.b.c")), + TestAction::assert_eq("let a=[];a[0]=a;a[1]=a;a[2]=a;a.join()", js_string!(",,")), ]); }