Skip to content

Instantly share code, notes, and snippets.

View iamgoangle's full-sized avatar
:octocat:
Focusing

Teerapong Singthong iamgoangle

:octocat:
Focusing
View GitHub Profile
@iamgoangle
iamgoangle / without_apply.js
Created August 11, 2017 07:52
call function without apply method
const args = [0, 1, 2];
function foo (x, y, z) {
// do stuff...
// we are not using this keyword in foo()
}
// Call function
foo.apply(null, args);
// Using ... instead
@iamgoangle
iamgoangle / concat_array.js
Created August 11, 2017 08:04
concatenate array
const arrA = [1, 2, 3];
const arrB = [4, 5, 6];
arrA.push(...arrB); // [1, 2, 3, 4, 5, 6]
let arrC = [1, 2, 3];
let arrD = [4, 5, 6];
arrC = [...arrC, ...arrD]; // [1, 2, 3, 4, 5, 6]
@iamgoangle
iamgoangle / insert_array.js
Created August 11, 2017 08:20
insert array at element we want
let lists = ['pizza', 'poo'];
let results = ['mark', ...lists, 'too'];
// result = ["mark", "pizza", "poo", "too"]
@iamgoangle
iamgoangle / copy_array.js
Created August 11, 2017 08:44
Copy array
let arrA = [1, 2, 3];
let copyA = [...arrA]; // [1, 2, 3] immutable
@iamgoangle
iamgoangle / spread_string.js
Created August 11, 2017 08:48
Spread string in to array
let name = 'Prayuth';
let spreadName = [...name]; // "P", "r", "a", "y", "u", "t", "h"]
@iamgoangle
iamgoangle / math_min.js
Created August 11, 2017 08:54
Using Math.min()
let number = [9, 8, 7, 1];
console.log(Math.min(number)); // NaN
console.log(Math.min(...number)); // 1
@iamgoangle
iamgoangle / destructuring_with_spread.js
Created August 11, 2017 09:01
Destructuring with spread
let { x, y, ...z } = { x: 1, y: 2, a: 3, b: 4 };
console.log(x); // 1
console.log(y); // 2
console.log(z); // { a: 3, b: 4 }
@iamgoangle
iamgoangle / merge_object.js
Created August 11, 2017 09:10
Merge object
const profile = {
name: 'Teerapong Singthong'
};
const position = {
job: 'Business Maker'
};
const summary = {...profile, ...position};
@iamgoangle
iamgoangle / merge_object_2.js
Created August 11, 2017 09:32
Merge Object 2
const profile = {
name: 'Teerapong Singthong'
};
const position = {
job: 'Business Maker'
};
const summary = {...profile, job: 'Developer'};
/*
@iamgoangle
iamgoangle / iterm2-solarized.md
Created August 13, 2017 09:10 — forked from kevin-smets/iterm2-solarized.md
iTerm2 + Oh My Zsh + Solarized color scheme + Meslo powerline font + [Powerlevel9k] - (macOS)

Default

Default

Powerlevel9k

Powerlevel9k