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 incrementUntil = function(max) { | |
if(num >= max) return num | |
num++ | |
incrementUntil(max) | |
} | |
var num = 0 | |
incrementUntil(3) | |
num //> 3 |
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 Person(name) { | |
var secret = “secret!” | |
this.name = name | |
this.setName = function(newName) { this.name = newName } | |
this.setNameToFoo = function() { this.name = foo } | |
this.getSecret = function() { return secret } | |
} | |
var a = new Person(“Max”) | |
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 express from 'express' | |
import path from 'path' | |
import fs from 'fs' | |
const app = express() | |
app.set("port", process.env.PORT || 3001) | |
// Middleware that serves static file ====================================== | |
app.use('/static', (req, res, next) => { |
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
//Currying is when you break down a function that takes multiple arguments into a //series of functions that take part of the arguments. | |
//converts a function f of two arguments into a function of one argument that partially applies f. | |
def curry[A,B,C](f: (A,B) => C): A => (B => C) = | |
(a: A) => (b: B) => f(a,b) | |
//> curry: [A, B, C](f: (A, B) => C)A => (B => C) |
NewerOlder