JSON stringify method converts a JavaScript object into a string (not an array).
JSON.stringify(value)
Example JSON stringify to array JavaScript
Simple HTML example code use the JavaScript function JSON.stringify() to convert it into a string. The output will be a string following the JSON notation.
<!DOCTYPE html>
<html>
<head>
<script>
var person={"first_name":"Tony","last_name":"Hawk","age":31};
console.log(person);
var res = JSON.stringify(person);
console.log(res);
console.log(typeof(res))
</script>
</head>
</html>
Output: Person is now a string, and ready to be sent to a server:
Do comment if you have any doubts or suggestions on this JS Array JSNO topic.
Note: The All JS Examples codes are tested on the Firefox browser and the Chrome browser.
OS: Windows 10
Code: HTML 5 Version