Skip to content
Create a gist now

Instantly share code, notes, and snippets.

@caleywoods /functions.js secret
Created Sep 18, 2012

/* This adds two methods first() and last() to Arrays.
* These methods are used throughout this file, removing
* them will cause things to break. If these need to be
* removed you need to replace first() with Array[0] and last
* with Array[array.length - 1]
Array.prototype.first = function () { return this[0]; };
Array.prototype.last = function () { return this[this.length - 1]; };
/* This adds a method to String objects that allows you to test
* whether or not a certain character or string exists in a target
* string. In raw JS you need to check for .indexOf("test") !== -1
String.prototype.contains = function( it ) { return this.indexOf( it ) !== -1; };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.