This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<meta http-equiv="Content-type" content="text/html; charset=utf-8"> | |
<title></title> | |
</head> | |
<body> | |
<div id="the_div"> | |
<ul id="the_list"> | |
<li id="the_item">Click me!</li> | |
</ul> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function convertToArray(iterable) { | |
return Array.prototype.slice.call(arguments); | |
} | |
Function.prototype.curry = function(){ | |
if (!arguments.length) return this; | |
var __method = this, args = convertToArray(arguments); | |
return function() { | |
return __method.apply(this, args.concat(convertToArray(arguments))); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var cachy = (function() { | |
var cache = {} | |
var executor = function(func, args) { | |
var funcIdentifier = func.toString(), | |
argsIdentifier = args.join(", ") | |
if(cache.hasOwnProperty(funcIdentifier) && cache[func.toString()].hasOwnProperty(argsIdentifier)) { | |
console.log("cached baby!") | |
return cache[funcIdentifier][argsIdentifier] | |
} else { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1. Write a class to support the following code: | |
var Person = function(name){ this.name = name } | |
var instanceMethods = { | |
getName: function(){ | |
return this.name | |
} | |
} | |
for(var name in instanceMethods) { | |
Person.prototype[name] = instanceMethods[name] | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+new Date |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1. Write a class to support the following code: | |
var Person = function(name){ this.name = name } | |
Person.prototype.getName = function(){ | |
return this.name | |
} | |
var thomas = new Person('Thomas'); | |
var amy = new Person('Amy'); | |
console.log(thomas.name) // --> "Thomas" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1. Write a class to support the following code: | |
var Person = function(name){ this.name = name } | |
Person.prototype = { | |
getName: function(){ | |
return this.name | |
} | |
} | |
var thomas = new Person('Thomas'); | |
var amy = new Person('Amy'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Exercise 2 - Closures | |
// Wrap the following code in a closure and export only the "countdown" function. | |
// Code | |
(function(name, obj) { | |
var index; | |
function log(){ | |
console.log(index); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Exercise 2 - Closures | |
// Wrap the following code in a closure and export only the "countdown" function. | |
// Code | |
(function(name, obj) { | |
var index; | |
function log(){ | |
console.log(index); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var tags = tags_text.split(','); | |
var errors = []; | |
if (errors.length > 0) { | |
} else { | |
var new_question = new db.Question({ | |
title: title, | |
body: body, | |
doNotify: doNotify, |