Posts Tagged ‘javascript’

Replace commas on string JavaScript

June 14, 2016 Leave a comment

var mystring = "This is a string, with commas, or, is it?";
var result = mystring.replace(/,/g , "|");

Categories: Beyond, JavaScript, Mini-tips

Remove duplicated elements, Array JavaScript

March 20, 2013 1 comment

I got this piece of code from stackoverflow, and im just sharing this cus this is something that I am usually looking for :P and this will save some time :), I am adding the source if you want to check out more options on how to do this.

function getDistinctArray(a) {
var d = {};
return a.filter(function(e) {
var h = e.valueOf(), i = d[h];
d[h] = true;
return !i;