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
// Airnb's style guide for writing better javascript | |
// Reference: https://github.com/airbnb/javascript | |
// Primitives | |
const foo = 1; | |
let bar = foo; | |
bar = 9; | |
console.log(foo, bar); // => 1, 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
// Arrows | |
// A function shorthand that binds `this` value. | |
// Arrow functions are always anonymous. | |
// | |
// // Basic syntax: | |
// (param1, param2, paramN) => { statements } | |
// (param1, param2, paramN) => expression | |
// equivalent to: => { return expression; } | |
// Parentheses are optional when there's only one argument: |
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 asyncFun = function(someUrl, resolve, reject) { | |
$.get(someUrl) | |
.done(function(response) { | |
if(response) { | |
resolve(response); | |
} else { |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>firebase</title> | |
</head> | |
<body> | |
<script src='https://cdn.firebase.com/js/client/2.2.1/firebase.js'></script> | |
<script> | |
// var ref = new Firebase('https://test231.firebaseio.com/'); |
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
// users | |
const users = [ | |
{ | |
id: 0, | |
name: "Rocky" | |
}, | |
{ | |
id: 1, | |
name: "John" | |
}, |
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
// https://npmcdn.com/@reactivex/[email protected]/dist/global/Rx.umd.js | |
Rx.Observable.create(function(observer) { | |
let counter = 0; | |
setInterval(function() { | |
observer.next((counter += 2)); | |
}, 2000); | |
}).subscribe( | |
function(val) { |
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
// Typescript Documentation: | |
// https://www.typescriptlang.org/docs/ | |
// Basic Types | |
const message: string = "Hello world"; | |
const messageArr: Array<string> = [message]; | |
console.log(message); | |
console.log(messageArr); | |
const isValid: boolean = false; |
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
{ | |
"editor.snippetSuggestions": "top", | |
"editor.suggestSelection": "first", | |
"editor.cursorSmoothCaretAnimation": false, | |
"editor.smoothScrolling": true, | |
"editor.fontSize": 14, | |
"editor.fontFamily": "Monaco", | |
"editor.fontWeight": "bold", | |
"editor.formatOnSave": true, | |
"emmet.triggerExpansionOnTab": 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
import * as React from "react"; | |
const Text = (props) => { | |
return ( | |
<div style={{ border: "1px solid red", padding: "20px" }}> | |
<p>this is text</p> | |
<div>{props.children}</div> | |
</div> | |
); | |
}; |
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
// 2 -> 8 -> 10 -> 4 -> 7 | |
// {value, next} | |
class Node { | |
constructor(value) { | |
this.value = value; | |
this.next = null; | |
} | |
} |