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 defaults = { file: null }; | |
function foo(options) { | |
// Merging defaults and options objects in ES6 | |
options = [ defaults, options ].reduce(Object.assign, {}); | |
} | |
foo({ file: "happy.md" }); |
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
<pre> | |
# Just Markdown, Yo. | |
So, I wanted to try to write the simplest webpage possible, [Max Ogden][1] | |
style. If you have JavaScript, you get something pretty. If not, then you see | |
[Markdown][2] text, which is fine too. | |
[1]: http://maxogden.com | |
[2]: http://daringfireball.net/projects/markdown/ | |
</pre> |
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
// Wire up LCD as described here: | |
// http://learn.adafruit.com/character-lcds/overview | |
var five = require("johnny-five"), | |
board, lcd; | |
board = new five.Board(); | |
board.on("ready", function() { |
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() { | |
var hasOwnProperty = Object.prototype.hasOwnProperty; | |
var Function = hasOwnProperty.constructor; | |
function isIdentifier(s) { | |
return /[a-zA-Z_$][a-zA-Z_$0-9]*/.test(s); | |
} |
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 five = require("johnny-five"), | |
board; | |
board = new five.Board(); | |
board.on("ready", function() { | |
(new five.Led(13)).on(); | |
var dataPin = 2; | |
var clockPin = 3; |
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
Airplane - "Apertem os cintos, o piloto sumiu" - Fasten your seatbelts, the pilot disappeared | |
Giant (George Stevens) - "Assim Caminha a Humanidade" - "This way walk humanity" | |
Mystic River - "Sobre meninos e lobos" - "About boys and wolves" | |
The Hangover - Se beber, não case - If you drink, don't drive | |
The Godfather - O Poderoso Chefão - The Great Boss | |
The Good Son - O Anjo Malvado - The Evil Angel | |
The Sound of Music - A Noviça Rebelde - The Rebel Nun | |
The Transporter - Carga Explosiva - Explosive Cargo | |
The Tuxedo - O Terno de 2 Bilhões de Dólares - The 2 billion dollars suit | |
Be Cool - O Outro Nome do Jogo - The other name of the game |
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
// A Dict class that works in ES6 using Map. Basically it's identical to Map, but | |
// only expected to be used on string keys. | |
function Dict() { | |
this.elts = new Map(); | |
} | |
// (string) -> any | |
Dict.prototype.get = function get(key) { | |
return this.elts.get(key); |
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
Object.defineProperty(Object.prototype, 'forIn', { | |
value: function(iterator, thisValue) { | |
Object.keys(this).forEach(function(key) { | |
iterator.call(thisValue, this[key], key, this); | |
}.bind(this)); | |
} | |
}); | |
var obj = {a: 1, b: 2}; |
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 originalNodeListProto = NodeList.prototype; | |
var temporaryNodeListProto = Object.create(NodeList.prototype); | |
temporaryNodeListProto.a = 1; | |
NodeList.prototype = temporaryNodeListProto; | |
var l = document.querySelectorAll('a'); | |
console.log(l.a); // inherited from which prototype? | |
NodeList.prototype = originalNodeListProto; |
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
//----- Example code: | |
// Class declarations: | |
// - No data properties allowed | |
// - Future: support mixins | |
// - Optional: call the initialization method `new` instead of `constructor` | |
// Superclass | |
class Person { | |
constructor(name) { |