如何把对象转换成数组

       Lodash是一个著名的javascript原生库,不需要引入其他第三方依赖。是一个意在提高开发者效率,提高JS原生方法性能的JS库。文档可通过官网下载,也可点此链接下载https://pan.baidu.com/s/1dFNYB8P(被吞了可以留言联系我)

      在lodash中有两种对象转换成数组的方法,一种是使对象属性值转换成数组,另一种是使对象的属性名转换成数组。

一:_.values(使对象属性值转换成数组)

_.values(object)

(Array): 返回对象属性的值的数组。

var items={"可口可乐":{"classification":"饮料","name":"可口可乐","unit":"瓶","price":"3","count":3,"subtotal":"6元(原价:    9元)","free_count":1,"free_money":3},"雪碧":{"classification":"饮料","name":"雪碧","unit":"瓶","price":"3","count":3,"subtotal":"6元(原价:    9元)","free_count":1,"free_money":3},"苹果":{"classification":"水果","name":"苹果","unit":"斤","price":"5.5","count":3,"subtotal":"16.5元","free_count":1,"free_money":3},"荔枝":{"classification":"水果","name":"荔枝","unit":"斤","price":"2","count":3,"subtotal":"6元","free_count":1,"free_money":3},"电池":{"classification":"生活用品","name":"电池","unit":"个","price":"15","count":2,"subtotal":"30元","free_co

你可能感兴趣的:(如何把对象转换成数组)