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 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 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 puke(object) { | |
| return <pre>{JSON.stringify(object, null, ' ')}</pre>; | |
| } |
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 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 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
| 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 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
| 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 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 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 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
| names2 = ['kendra', 'kim', 'kampbell']; | |
| var capitalize = function(word) { | |
| return word[0].toUpperCase() + word.slice(1); | |
| }; | |
| map(names, capitalize); // ['Kendra', 'Kim', 'Kampbell'] |
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
| 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 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 i; | |
| var names = ['jon', 'jane', 'jack']; | |
| // imperative programming | |
| for (i = 0; i < names.length; i++) { | |
| names[i] = names[i][0].toUpperCase() + names[i].slice(1); | |
| } | |
| console.log(names) // ['Jon', 'Jane', 'Jack'] | |
| console.log(i) // 3 |
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 i; | |
| var names = ['jon', 'jane', 'jack']; | |
| // imperative programming | |
| for (i = 0; i < names.length; i++) { | |
| names[i] = names[i][0].toUpperCase() + names[i].slice(1); | |
| } | |
| console.log(names) // ['Jon', 'Jane', 'Jack'] | |
| console.log(i) // 3 |