how to fetch array keys with jQuery?

前端 未结 6 995
北海茫月
北海茫月 2020-12-03 04:19

Good afternoon. I have an array with some keys, and values in them. I then need to fetch the array keys and not the data in them. I want to do this with jQuery. I know for e

6条回答
  •  臣服心动
    2020-12-03 05:00

    Using jQuery, easiest way to get array of keys from object is following:

    $.map(obj, function(element,index) {return index})
    

    In your case, it will return this array: ["alfa", "beta"]

提交回复
热议问题