Turn properties of object into a comma-separated list?

前端 未结 10 1712
-上瘾入骨i
-上瘾入骨i 2021-02-01 02:42

I have an object like this:

var person = {
  name: \"John\",
  surname: \"Smith\",
  phone: \"253 689 4555\"
}

I want:



        
10条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-01 03:21

    Here is a simpler one liner. It uses the Object.values() method instead of Object.keys

    Object.values(obj).join(",");
    

提交回复
热议问题