Search code examples
prototypeprototypal-inheritance

Why prototype of array is an array


Prototype of a function is a Function. Prototype of an array is an Array. Prototype of an object is an Object.

WHY?


Solution

  • Prototype of a function is a Function.

    function inherit from Prototype function
    this what it look like = function(){}
    the type is function

    Prototype of an array is an Array.

    Array inherit from Prototype Array this what it look like = []
    the type is Array
    you can insert to that by push= [].push('why you ask basic question')
    and you can call it by = array_name[0]

    Prototype of an object is an Object

    Object inherit from Prototype Object
    this what it look like = {}
    the type is Object
    you can insert to that by = {}['question']='why you ask basic question'
    and you can call it by = obj_name['question']

    do you know function,Object,Array? the prototype just constructure for it so when the error say prototype function is error that mean your function sistem not right, you not type it right or you not do it right, some think must be crush on it repair it