Simple:

var data = [{"name":"Marine Lines","location_id":3},{"name":"Ghatkopar","location_id":2}]
var result = data.map(function(val) {
  return val.location_id;
}).join(',');

console.log(result)

I assume you wanted a string, hence the .join(','), if you want an array simply remove that part.

Answer from Chrillewoodz on Stack Overflow
🌐
OneCompiler
onecompiler.com › javascript › 3xfqsme8y
convert a json array of objects to comma separated values - JavaScript - OneCompiler
Executable in both browser and server which has Javascript engines like V8(chrome), SpiderMonkey(Firefox) etc. var readline = require("readline") var rl = readline.createInterface({ input: process.stdin, output: process.stdout, terminal: false, }) rl.on("line", function (line) { console.log("Hello, " + line) }) ... An array is a collection of items or values.
Discussions

JavaScript: How to get comma separated string from json string? - Stack Overflow
I have a JSON string value that corresponds to this object: { "id" : "122223232244", "title" : "התרעת פיקוד העורף", "data" : ["עוטף עזה 218","עוטף עזה 217"] } I am trying to extract the following... More on stackoverflow.com
🌐 stackoverflow.com
June 13, 2019
Json to array comma
Hello everyone. I trying to convert a json data to a string comma separated. Json is like this one: [ { "id": "625d757724acbe52634e6172", "idBoard": "625850ac4247c214ff3dc167", "name": "ANGELIS", "color": "yellow" }, { "id": "625d57da6bfa728b6684ed43", "idBoard": "625850ac4247c214ff3dc167", ... More on community.n8n.io
🌐 community.n8n.io
0
0
May 16, 2022
How to convert array into comma separated string in javascript - Stack Overflow
I have an array: a.value = [a,b,c,d,e,f] How can I convert to comma-seperated string like: a.value = "a,b,c,d,e,f" More on stackoverflow.com
🌐 stackoverflow.com
javascript - Get comma separated string from array - Stack Overflow
Is it correct to assume you made a typo and what you want is one string instead of several comma-separated strings? ... why do you want to convert a JSON array (with is supported by the JSON format) to a comma separated string? I can't think of a good reason to do it. More on stackoverflow.com
🌐 stackoverflow.com
May 24, 2017
🌐
Experts Exchange
experts-exchange.com › questions › 28652216 › How-to-get-convert-json-array-to-comma-separated-values.html
Solved: How to get convert json array to comma separated values | Experts Exchange
April 8, 2015 - What exception do you get and what JSONTokener are you using ? http://www.massapi.com/class/js/JSONTokener-1.html#Example6 And I believe this should work · String input ='[{"filter":"ID","filterValues":["050886","050885","050884","050883","050882"]}]'; JSONArray jsonarray = (JSONArray) new JSONTokener(input ).nextValue(); for (int i = 0; i < jsonarray.length(); i++) { JSONObject jsonobject = jsonarray.getJSONObject(i); String field= jsonobject.getString("filter"); String values= jsonobject.getJSONObject("filterValues"); }
🌐
ServiceNow Community
servicenow.com › community › developer-forum › convert-array-string-to-comma-separated-string › m-p › 2606171
Convert Array String to Comma Separated String - ServiceNow Community
July 6, 2023 - Hi, I suspect your issue is that your array is an array of objects, and so may need to iterate through the sorted array stringifying each element\object and concatenating these individually to your output string. ... var tempString = ''; for(key in sortedArray) { tempString = tempString + JSON.stringify(sortedArray[key]); }
🌐
n8n
community.n8n.io › questions
Json to array comma - Questions - n8n Community
May 16, 2022 - Hello everyone. I trying to convert a json data to a string comma separated. Json is like this one: [ { "id": "625d757724acbe52634e6172", "idBoard": "625850ac4247c214ff3dc167", "name": "ANGELIS", "color": "yellow" }, { "id": "625d57da6bfa728b6684ed43", "idBoard": "625850ac4247c214ff3dc167", ...
Find elsewhere
🌐
Reddit
reddit.com › r/javascripttips › how do i convert an array to a string with commas in javascript
r/JavaScriptTips on Reddit: How do I convert an array to a string with commas in JavaScript
April 13, 2023 -

In JavaScript, you can convert an array to a string with commas using the join()
method.

The join() method returns a string that concatenates all the elements of an array, separated by the specified separator, which in this case is a comma.

Here is an example:

const array = ['apple', 'banana', 'orange'];
const string = array.join(', ');
console.log(string); 

// output: "apple, banana, orange"

In this example, we first define an array of three fruits. Then we use the join()
method with a comma and a space as the separator to create a string that lists all the fruits with a comma and a space between each one.

You can replace the comma and space separator with any other separator you like, such as a hyphen, a semicolon, or a newline character.

It's important to note that the join() method only works on arrays, and it will throw an error if you try to use it on any other type of object.

Click here to learn more ways to Convert Array to String with Commas in JS

🌐
Microsoft Power Platform Community
powerusers.microsoft.com › t5 › Building-Flows › JSON-received-as-a-comma-separated-string-need-help-in › td-p › 676482
https://powerusers.microsoft.com/t5/Building-Flows...
Quickly search for answers, join discussions, post questions, and work smarter in your business applications by joining the Microsoft Dynamics 365 Community.
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › create-a-comma-separated-list-from-an-array-in-javascript
Create a Comma Separated List from an Array in JavaScript - GeeksforGeeks
July 11, 2025 - The code uses map(String) to convert each element of the array arr into a string, and then join(',') joins these string elements with commas. The result is a comma-separated string "1,2,3,4,5", which is logged to the console.
🌐
Wappler Community
community.wappler.io › wappler general › need help
Show json array field as comma separated values - Need Help - Wappler Community
July 1, 2023 - I have a JSON field which stored days of the week. I want to show those in my list but it’s displaying them like this: ["Mon","Tue","Wed","Thu","Fri"] I’m sure it must be easy to change this but cannot find how. I wan…