xxxxxxxxxx
const classNames = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"]
function getClassName() {
return classNames.join(" ").toString()
}
console.log(getClassName()) // a b c d e f g h i j
xxxxxxxxxx
var cars = ["Volvo", "BMW", "Audi", "Chevrolet"];
console.log(cars.toString());
//Output: Volvo,BMW,Audi,Chevrolet
xxxxxxxxxx
const cities = ['London', 'Paris', 'Tokyo'];
const joinedCities = cities.join();
console.log(joinedCities); // London,Paris,Tokyo
xxxxxxxxxx
// convert an array to string javascript
// using reduce()
let array = ['A', 'quick', 'brown', 'fox', 'jumps', 'over', 'the', 'lazy', 'dog'];
let output = array.reduce((a, b) => a + ' ' + b);
console.log(output); //A quick brown fox jumps over the lazy dog
// using join()
let output1 = array.join(" ");
console.log(output1); //A quick brown fox jumps over the lazy dog
xxxxxxxxxx
print_r($request->education); //It is an array print
$str_json = json_encode($request->education); //array to json string conversion
echo $str_json; // printing json string
print_r(json_decode($str_json)); //printing array after convert json string to array
exit; // exiting further execution to check resutls
xxxxxxxxxx
const str = 'javascript';
const arr = [str];
// output:
// ['j', 'a', 'v', 'a', 's', 'c', 'r', 'i', 'p', 't']
xxxxxxxxxx
const str = "javascript";
const arr = str.split('');
console.log(arr);
// output:
// ['j', 'a', 'v', 'a', 's', 'c', 'r', 'i', 'p', 't']