Skip to content

Instantly share code, notes, and snippets.

@chardos
Created December 15, 2015 12:55
Show Gist options
  • Save chardos/5c5d9b1f79067fec8aad to your computer and use it in GitHub Desktop.
Save chardos/5c5d9b1f79067fec8aad to your computer and use it in GitHub Desktop.
Call array methods on string
var original = "There is 1 number.";
var updated = Array.prototype.filter.call(original, function(val) {
return val.match(/1/);
});
// Outputs: ["1"]
console.log(updated);
// Outputs: "1"
console.log(updated.join(''));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment