Creating array-like objects in JavaScript

后端 未结 5 1258
轻奢々
轻奢々 2020-12-02 15:53

In JavaScript, there are objects that pretend to be arrays (or are \"array-like\"). Such objects are arguments, NodeLists (returned from get

5条回答
  •  青春惊慌失措
    2020-12-02 16:35

    I think this is what you are looking for. Override the toString function.

    foo.prototype.toString = function()
    {
        return "[object Foo <" + this[0] +">]";
    }
    

提交回复
热议问题