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
| 'use strict'; | |
| function mul(x) { | |
| return x * x; | |
| } | |
| function mulWVariance(variance, x) { | |
| return x * x + variance; | |
| } |
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
| 'use strict'; | |
| function chain() { | |
| var newReleases = [{ | |
| "id": 70111470, | |
| "title": "Die Hard", | |
| "rating": 4.0 | |
| }, { | |
| "id": 654356453, | |
| "title": "Bad Boys", |
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 ViewSomething() { | |
| this.a = 42 | |
| this.click = function() => { | |
| alert(this.a) // undefined | |
| } | |
| this.click1 = () => { | |
| alert(this.a) // 42 |
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
| // npm i node-uuid | |
| var uuid = require('node-uuid'); | |
| // Generate a v1 (time-based) id | |
| uuid.v1(); | |
| // Generate a v4 (random) id | |
| uuid.v4(); |
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
| // Mutated Version | |
| const combineReducers = reducers => { | |
| return (state = {}, action) => { | |
| return Object.keys(reducers).reduce((nextState, key) => { | |
| nextState[key] = reducers[key](state[key], action) | |
| return nextState | |
| }, {}) | |
| } | |
| }; |
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 parts = ['shoulders', 'knees']; | |
| var parts2 = ['head', 'and', 'toes']; | |
| // ES 5 | |
| var lyrics = parts2.slice(0, 1).concat(parts).concat(parts2.slice(1, 3)); | |
| console.log(lyrics); // ["head", "shoulders", "knees", "and", "toes"] | |
| // ES 6 | |
| var lyrics = [parts2[0], ...parts, parts2[1], parts2[2]]; | |
| console.log(lyrics); // ["head", "shoulders", "knees", "and", "toes"] |
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
| // This is a simple *viewmodel* - JavaScript that defines the data and behavior of your UI | |
| function AppViewModel() { | |
| this.lastName = ko.observable("Bertington"); | |
| this.capitalizeLastName = function() { | |
| var currentVal = this.lastName(); // Read the current value | |
| this.lastName(currentVal.toUpperCase()); // Write back a modified value | |
| }; | |
| } | |
| // Activates knockout.js |
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 realSum(a, b) { | |
| return a + b; | |
| }; | |
| console.log(realSum(5, 3)); // 8 | |
| var sum5 = curryIt(realSum, 5); | |
| console.log(sum5(4)); // 9 |
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 timeConvertor(time) { | |
| var PM = time.match('PM') ? true : false | |
| time = time.split(':') | |
| var min = time[1] | |
| if (PM) { | |
| var hour = 12 + parseInt(time[0],10) | |
| var sec = time[2].replace('PM', '') |
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 config = { | |
| entry: { | |
| app: addEntryPoint('./src/Router.jsx'), | |
| vendor: ['lodash', 'react', 'react-router', 'react-dom', 'rc-slider'] | |
| }, | |
| output: { | |
| path: options.devServer ? path.join( __dirname, 'public', 'js') : 'public', | |
| filename: '[name]-[chunkhash].js', | |
| publicPath: '', |