I am very new to JS and am trying to learn to remove the commas from an array i.e. (Object.getOwnPropertyNames(window))
When I try to run the split I keep getting "Uncaught TypeError: myVar.split is not a function"
//my array
myVar = (Object.getOwnPropertyNames(window));
document.writeln(myVar)
//to remove commas
var newVar = myVar.split(',');
document.writeln(newVar);
https://jsfiddle.net/8ywq0dt3/1
Hoping someone can help a novice out....
Thanks Mike
split()method. If you mean you want to format the array as a string without commas, you probably wantmyVar.join("some delimiter that's not a comma"). See Array.prototype.join()toString()method that is invoked when you try to use them in a string context. The behaviour of Array.prototype.toString() is well documented