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

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -