Javascript join(), i want to join some of them in array -


in case example, have array :

var myarr = ["red", "green", "blue", "yellow"]; 

question: how join "myarr", except "red" or 1 of them, or want join of them (example). example, becomes below: greenblueyellow advice..

you can use array.prototype.filter()

var filterval = 'green'; var joinedstring = myarr.filter(function(item){     return item !== filterval; }).join();  alert(joinedstring); 

demo


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -