hi i have one array in my js file.I want to write this array and save it as newfile.js in a specific path is that possible??
My Js file with array
var myArray = new Array();
myArray[0] = "News";
myArray[1] = "Sports";
myArray[2] = "International";
// i want to save this myArray to a new js file.
var jsondata= JSON.stringify(myArray);
//Node Js code
fs.appendFile("/chat.js",jsondata, function(err) {
if(err) {
console.log(err);
} else {
console.log("The file was saved!");
}
});
Please help me