If value is not a plain array, such code will work fine:

var value = { "aaa": "111", "bbb": "222", "ccc": "333" };
var blkstr = [];
$.each(value, function(idx2,val2) {                    
  var str = idx2 + ":" + val2;
  blkstr.push(str);
});
console.log(blkstr.join(", "));
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>

(output will appear in the dev console)

As Felix mentioned, each() is just iterating the array, nothing more.

Answer from user447356 on Stack Overflow
🌐
W3Schools
w3schools.com › jsref › jsref_tostring_array.asp
JavaScript Array toString() Method
The toString() method returns a string with array values separated by commas.
🌐
CodingNomads
codingnomads.com › javascript-array-to-string-conversion
JavaScript Array-String Conversion
Learn how to seamlessly convert between arrays and strings in JavaScript using methods like .join(), .split(), and more.
🌐
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

🌐
Tabnine
tabnine.com › home › array to string in javascript
Array to String in JavaScript - Tabnine
July 25, 2024 - JavaScript’s toString() method operates on a given object, returning its text representation as a string. Applying the toString() method to an array returns the values in the array as a string.
🌐
ReqBin
reqbin.com › code › javascript › ot8wzla9 › javascript-array-to-string-example
How do I convert array to string in JavaScript?
November 21, 2023 - You can also create a multiline string, check if it starts or ends with another string, and get the length of a string. In JavaScript, you can convert an array to a string using the Array.join(separator) and array.toString() methods.
Find elsewhere
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › convert-array-to-string-in-javascript
Convert Array to String in JavaScript - GeeksforGeeks
July 23, 2025 - The JSON.stringify() method converts an array including even the nested arrays and objects to a JSON string.
🌐
Medium
medium.com › konsole-blog › 5-ways-to-convert-array-to-string-in-javascript-f6a92ac5788f
5 ways to convert Array to String in Javascript | by David Petrosyan | Konsole.blog | Medium
May 23, 2022 - We check to see if the element is equal to 'b'. If it is, we append that element with a separator. Otherwise we append the element without the separator. You can also use the array.reduce() method for joining with custom logic. The previous example with a for loop can be rewritten like this: const myArray = ['a', 'b', 'c', 'c', 'b', 'a', 'd']const myString = myArray.reduce((stringAccumulator, currentElement) => { const separator = ';' if (currentElement === 'b') { return stringAccumulator += (currentElement + separator) } return stringAccumulator += currentElement }, '')console.log(myString) // 'ab;ccb;ad'
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › javascript-array-tostring-method
JavaScript Array toString() Method - GeeksforGeeks
July 14, 2024 - JS Tutorial · Web Tutorial · A to Z Guide · Projects · OOP · DOM · Set · Map · Math · Number · Boolean · Exercise · Last Updated : 14 Jul, 2024 · The toString() method returns a string with array values separated by commas.
🌐
DEV Community
dev.to › gaelgthomas › array-to-string-without-commas-in-javascript-4mg6
Array to String Without Commas in JavaScript - DEV Community
September 18, 2022 - In JavaScript, all arrays have a built-in method called join(). You can use it to convert an array to a string without commas. You can call the join method with an empty string as a parameter (join("")).
🌐
Alma Better
almabetter.com › bytes › articles › array-to-string-javascript
How to Convert Array to String in JavaScript
June 20, 2024 - You can use this feature to convert an array to a string by iterating over its elements. ... In some cases, you might need more control over the array to string conversion process.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Array › join
Array.prototype.join() - JavaScript - MDN Web Docs
The join() method of Array instances returns a new string that is the concatenation of all elements in this array, separated by commas or a specified separator string. If the array has only one item, that item's stringification is returned without using the separator.
🌐
Medium
medium.com › @louistrinh › converting-arrays-to-strings-in-javascript-4d1bbea80c20
Converting Arrays to Strings in JavaScript | by Louis Trinh | Medium
November 20, 2024 - The built-in toString() method on Arrays converts each element to a String and joins them with commas.
🌐
Will Vincent
wsvincent.com › javascript-convert-array-to-string
JavaScript: Convert Array to a String | Will Vincent
January 3, 2018 - Finally, if you can’t use a built-in method for some reason, you can loop through the array and convert it to a string manually. // 1. Use .toString() ['a', 'b', 'c'].toString(); // 'a,b,c' // 2. Coerce to string ['a', 'b', 'c'] + []; // 'a,b,c' ['a', 'b', 'c'] + ''; // 'a,b,c' // 3. Use .join() ['a', 'b', 'c'].join(); // 'a,b,c' (defaults to ',' separator) ['a', 'b', 'c'].join(''); // 'abc' ['a', 'b', 'c'].join('-'); // 'a-b-c' // 4. Use JSON.stringify() JSON.stringify(['a', [1], 'b', 'c']); // '['a', [1], 'b','c']' // 5.
🌐
TutorialsPoint
tutorialspoint.com › article › how-to-convert-an-array-into-javascript-string
How to convert an array into JavaScript string?
March 15, 2026 - The toString() method is a built-in JavaScript function that converts array elements into a comma-separated string.
🌐
Mastering JS
masteringjs.io › tutorials › fundamentals › array-tostring
Array toString() in JavaScript - Mastering JS
December 8, 2021 - To convert an array to a string in JavaScript, you can use the toString() method.
🌐
YouTube
youtube.com › watch
JavaScript Basics - How To Convert An Array Into A String - YouTube
In this tutorial I'll show you how to convert an array into a string in JavaScript.-------------------------------------------------------------------All my ...
Published: November 18, 2024