Extract only values from JSON object in javascript without using a loop

前端 未结 4 992
暖寄归人
暖寄归人 2021-01-14 03:01

is there a \"Nice\" way to get all the values out of a json object (I don\'t care about the keys) - just get the values into array, without using a loop ? (lang is Javascr

4条回答
  •  [愿得一人]
    2021-01-14 03:12

    I think you are looking for Object.values() function, just pass the object to the values method of Object as first param. That's it!

    Object.values({something: 'lol'});
    > ["lol"]
    

提交回复
热议问题