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 xhr = new XMLHttpRequest(); | |
xhr.open('GET', '/my/url'); //xhr.open(method, URL, async, user, password) | |
xhr.send(); //xhr.send([body]) | |
//xhr.abort() to cancel the request | |
//also more convenience way to use | |
//onload onerror events |
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
{ "_id" : ObjectId("56921bc7ae2a196644a46bbd"), "hello" : "mongoShell" } |
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
// ES7, async/await | |
function sleep(ms = 0) { | |
return new Promise(r => setTimeout(r, ms)); | |
} | |
(async () => { | |
console.log('a'); | |
await sleep(1000); | |
console.log('b'); | |
})() |
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(self) { | |
'use strict'; | |
if (self.fetch) { | |
return | |
} | |
function normalizeName(name) { | |
if (typeof name !== 'string') { | |
name = String(name) |
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
// Factories for creating new btns | |
// app/components/btnDefaultFactory.js | |
export default const btnDefaultFactory = (customOpts) => { | |
const defaultOpts = { | |
size: 12, | |
color: 'powderblue', | |
state: 'brand new' | |
}; | |
return { ...defaultOpts, ...customOpts }; |
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
// Let's get hold of those elements | |
var outer = document.querySelector('#outer'); | |
var inner = document.querySelector('#inner'); | |
// Let's listen for attribute changes on the | |
// outer element | |
new MutationObserver(() => { | |
console.log('mutate'); | |
}).observe(outer, { | |
attributes: true |
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
const file1 = getSync('file1.json'); | |
const file2 = getSync('file2.json'); | |
const file3 = getSync('file3.json'); | |
console.log(file1); | |
console.log(file2); | |
console.log(file3); |
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 baz() { | |
throw new Error('Oops!'); | |
} | |
function bar() { | |
return baz(); | |
} | |
function foo() { | |
bar(); |
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 multiple(a, b) { | |
return a * b; | |
} | |
function square(n) { | |
return multiple(n, n); | |
} | |
function printSquare(n) { | |
console.log(square(n)); |
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
const o1 = { | |
prop: 'prop' | |
} | |
const o2 = Object.setPrototypeOf({ | |
prop2: 'prop2' | |
}, o1); | |
console.log(o2.prop2, o2.prop) |