This file contains 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
names2 = ['kendra', 'kim', 'kampbell']; | |
var capitalize = function(word) { | |
return word[0].toUpperCase() + word.slice(1); | |
}; | |
map(names, capitalize); // ['Kendra', 'Kim', 'Kampbell'] |
This file contains 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 d = 'not modified'; | |
// add is a pure function that doesn't modify anything out of its scope | |
function add(x, y) { | |
return x + y; | |
} | |
add(2, 3) // 5 | |
add(2, 3) // always gonna be 5 | |
console.log(d) // 'not modified' |
This file contains 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
names2 = ['kendra', 'kim', 'kampbell']; | |
// use this as your callback function in map | |
var capitalize = function(word) { | |
return word[0].toUpperCase() + word.slice(1); | |
}; | |
// we need each implemented for map to work | |
var each = function(array, callback) { | |
for (var i = 0; i < array.length; i++) { |
This file contains 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
import React from "react"; | |
import { render } from "react-dom"; | |
const ParentComponent = React.createClass({ | |
getDefaultProps: function() { | |
console.log("ParentComponent - getDefaultProps"); | |
}, | |
getInitialState: function() { | |
console.log("ParentComponent - getInitialState"); | |
return { text: "" }; |
This file contains 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 React = require('react'); | |
var PropTypes = React.PropTypes; | |
var styles = require('../styles'); | |
var Link = require('react-router').Link | |
var UserDetails = require('../components/UserDetails'); | |
var UserDetailsWrapper = require('../components/UserDetailsWrapper'); | |
function puke(object) { | |
return <pre>{JSON.stringify(object, null, ' ')}</pre>; | |
} |
This file contains 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 puke(object) { | |
return <pre>{JSON.stringify(object, null, ' ')}</pre>; | |
} |
This file contains 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 Bee = function () { | |
Grub.call(this); | |
this.age = 5; | |
this.color = 'yellow'; | |
this.job = 'keep on growing'; | |
}; | |
Bee.prototype = Object.create(Grub.prototype); | |
Bee.prototype.constructor = Bee; |
This file contains 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
"use strict" | |
var LimitedArray = function (limit) { | |
var storage = []; | |
var limitedArray = {}; | |
limitedArray.get = function (index) { | |
checkLimit(index); | |
return storage[index]; | |
}; |
This file contains 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
"use strict" | |
var LimitedArray = function (limit) { | |
var storage = []; | |
var limitedArray = {}; | |
limitedArray.get = function (index) { | |
checkLimit(index); | |
return storage[index]; | |
}; |
This file contains 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 http = require("http"), | |
url = require("url"), | |
path = require("path"), | |
fs = require("fs") | |
port = process.argv[2] || 8888; | |
http.createServer(function(request, response) { | |
var uri = url.parse(request.url).pathname | |
, filename = path.join(process.cwd(), uri); |