简体   繁体   中英

How to convert an object to a string without adding a bunch of commas?

I have this object that I want to convert to a string, but when I do its also adding all of the commas that iit had as an array. How can I remove those without turning it back into an array? ",2,3,5,0,8,8,7,9,9,0,7,4,4,8,4,2,2,4,"

You could replace and trim

 const str = ",2,3,5,0,8,8,7,9,9,0,7,4,4,8,4,2,2,4," const res = str.replace(/,/g, " ").trim() console.log(res)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM