Array functions in jQuery

后端 未结 8 1015
小鲜肉
小鲜肉 2020-12-13 08:55

I am using jQuery in my web application. I want to use arrays, but I am not able to find out functions for arrays (add, remove or append elements in array) in jQuery. Is the

8条回答
  •  没有蜡笔的小新
    2020-12-13 09:21

    You can use Underscore.js. It really makes things simple.

    For example, removing elements from an array, you need to do:

    _.without([1, 2, 3], 2);
    

    And the result will be [1, 3].

    It reduces the code that you write using jQuery.grep, etc. in jQuery.

提交回复
热议问题