Skip to content

Instantly share code, notes, and snippets.

@ojii
Created February 3, 2012 17:48
Show Gist options
  • Save ojii/1731362 to your computer and use it in GitHub Desktop.
Save ojii/1731362 to your computer and use it in GitHub Desktop.
Pythonify Javascript
// Array
Array.prototype.remove = function(ele){var index = this.indexOf(ele); if(index != -1){this.splice(index, 1);}};
Array.prototype.copy = function(){return this.slice(0);};
// String
String.prototype.endswith = function(suffix) {return this.indexOf(suffix, this.length - suffix.length) !== -1;};
String.prototype.startswith = function(prefix) {return this.indexOf(prefix) === 0;};
String.prototype.join = function(seq){return seq.join(this);};
String.prototype.isdigit = function(){return !isNaN(parseInt(this));};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment