diff --git a/misc/wasm/wasm_exec.js b/misc/wasm/wasm_exec.js
index ecb096509fb7ebdac281a97405c86201bffbba32..3617c498664522955f76754845e4fcc6d43e2232 100644
--- a/misc/wasm/wasm_exec.js
+++ b/misc/wasm/wasm_exec.js
@@ -141,7 +141,7 @@
 				}
 
 				let ref = v[this._refProp];
-				if (ref === undefined) {
+				if (ref === undefined || this._values[ref] !== v) {
 					ref = this._values.length;
 					this._values.push(v);
 					v[this._refProp] = ref;
diff --git a/src/syscall/js/js_test.go b/src/syscall/js/js_test.go
index 497b9467bbeab7b61bb93b0c08933f7ddbd4daa8..c4141c2196ede9bbe0c0e89d8b706015002da9ce 100644
--- a/src/syscall/js/js_test.go
+++ b/src/syscall/js/js_test.go
@@ -107,6 +107,13 @@ func TestObject(t *testing.T) {
 	if dummys.Get("someArray") != dummys.Get("someArray") {
 		t.Errorf("same value not equal")
 	}
+
+	// An object and its prototype should not be equal.
+	proto := js.Global().Get("Object").Get("prototype")
+	o := js.Global().Call("eval", "new Object()")
+	if proto == o {
+		t.Errorf("object equals to its prototype")
+	}
 }
 
 func TestTypedArrayOf(t *testing.T) {