Skip to content

Instantly share code, notes, and snippets.

View codemilli's full-sized avatar
😇
Hooked on React Hooks

codemilli codemilli

😇
Hooked on React Hooks
View GitHub Profile
const a = { prop: 'haha' };
console.log('prop => ', a.prop); // haha
a.prop = 'hihi';
console.log('prop => ', a.prop); // hihi
const a = 'haha'; // a = 'haha'
a = 'hihi'; // Assignment to constant variable
var a = 'hacker'; // a = 'hacker'
var a = 'moon'; // a = 'moon'
let b = 'hacker'; // b = 'hacker'
let b = 'pinky'; // Identifier 'b' has already been declared
if (true) {
console.log('a => ', a); // undefined
console.log('b => ', b); // b is not defined
var a = 'hacker';
let b = 'pinky';
}
if (true) {
var a = 'hacker';
let b = 'moon';
console.log('a => ', a); // hacker
console.log('b => ', b); // moon
}
console.log('a => ', a); // hacker
console.log('b => ', b); // b is not defined
class Rational(n: Int, d: Int) {
require(d != 0)
private val g = gcd(n.abs, d.abs)
val number = n /g
val denom = d / g
def this (n: Int) = this(n, 1)
def + (that: Rational): Rational =
class Rational(x: Int, y: Int) {
require(y != 0, "denominator must be nonzero");
def this(x: Int) = this(x, 1)
private def gcd(a: Int, b: Int): Int = if (b == 0) a else gcd(b, a % b)
private val g = gcd(x, y)
def numer = x / g
def denom = y / g
@codemilli
codemilli / introrx.md
Created February 28, 2016 10:42 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
export default function combineReducers(reducers) {
var reducerKeys = Object.keys(reducers)
var finalReducers = {}
for (var i = 0; i < reducerKeys.length; i++) {
var key = reducerKeys[i]
if (typeof reducers[key] === 'function') {
finalReducers[key] = reducers[key]
}
}
var finalReducerKeys = Object.keys(finalReducers)