Recreating underscore functions using only JavaScript