Why is the prototype chain not equal?

var arr = [];
arr.toString = = Object.prototype.toString / / false

Mar.05,2021

Array rewrote toString
[] .toString = Array.prototype.toString


arr.toString=Array.prototype.toString
true

because this is an array. You can assume that the array inherits the prototype chain of the object, but rewrites some functions, so it can't be relative. Similarly, can you tostring an object the same as an array tostring


although Array inherits the toString method of Object , it is generally rewritten with its own characteristics

.
var arr = [];
var reg = /sdsd/;
Object.prototype.toString.call(arr); //"[object Array]"
Object.prototype.toString.call("sss");//"[object String]"
Object.prototype.toString.call("reg");//"[object RegExp]"

[].constructor= Array() { [native code] }
{}.constructor= Object() { [native code] }

Menu