Array.push return pushed value?

前端 未结 6 1951
盖世英雄少女心
盖世英雄少女心 2021-01-04 02:30

Are there any substantial reasons why modifying Array.push() to return the object pushed rather than the length of the new array might be a bad idea?

I

6条回答
  •  梦谈多话
    2021-01-04 03:13

    var arr = [];
    var element = Math.random();
    assert(element === arr[arr.push(element)-1]);
    

提交回复
热议问题