Js Object and Array prototypes and inheritance

Array.prototype.toString = function(){
              console.log("");
            }
            
            var arr = [1,2,3];
            arr.toString();
            
            console.log(Object.prototype.toString.call(arr));

after the toString of the array is rewritten, the method of the array is called directly, and the method after the rewrite will be executed, but the toString on the object prototype will not be modified. We know that Array is also an object, and the method of Array can be inherited from the object Object, so what is the relationship between the object and the array? Is an array an instance of an object? Or what? Ask the great god for help in the analysis

Dec.24,2021

first of all, generally speaking, everything is an object. When you use the instanceof operator to determine whether the return value is true, but your typeof array is an array


javascript has no concept of class and is based on the prototype, so both Array and Object are objects. Array is not an instance of Object, but the inheritance of the Array prototype chain
Array.prototype.__proto__ = Object.prototype
var arr =
arr instanceof Array / true
arr instanceof Object / / true

.

typeof arr / / 'object', object is returned

Menu