Turn properties of object into a comma-separated list?

前端 未结 10 1691
-上瘾入骨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:28

    You can use this one-liner in modern browsers

    Object.keys(person).map(function(k){return person[k]}).join(",");
    

提交回复
热议问题