This file contains 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 NodeList = function() {}; | |
var nodeListExtras = {x: 23}; | |
mixin(NodeList.prototype, Array.prototype, nodeListExtras); | |
function mixin(obj /*, mixins*/) { | |
var mixins = [].slice.call(arguments, 1); | |
for (var i=0; i<mixins.length; i++) { | |
var thisMixin = mixins[i]; | |
var props = Object.getOwnPropertyNames(thisMixin); | |
for (var j=0; j<props.length; j++) { |
This file contains 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 mixin(obj, fn) { | |
fn.call(obj); | |
} | |
//this gets bound dynamically | |
var withCircleUtils = function() { | |
this.area = function() {return this.radius * this.radius * Math.PI}; | |
this.diameter = function() {return this.radius + this.radius}; | |
} |
This file contains 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
//shim of ES5.1 internal ToPrimitive method | |
//see http://es5.github.com/#x9.1 | |
//assumes no hint argument (as is the case with == operands) | |
var ToPrimitiveNoHint = function(value) { | |
if (typeof value != 'object') { | |
return value; | |
} | |
if (typeof value.valueOf() != 'object') { | |
return value.valueOf(); |
This file contains 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 withStorage() { | |
if (window.localStorage) { | |
localStorage.call(this); | |
} else if (document.documentElement.addBehavior) { | |
userData.call(this); | |
} else { | |
memory.call(this); | |
} |
This file contains 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
define( | |
[], | |
function () { | |
var utils = { | |
//object properties | |
}; | |
This file contains 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
// Arrow functions would have been useful for defining concise formulae to be invoked in | |
// the context of other objects. | |
// For example here's an object describing a piece of rope. It includes a method which | |
// returns the area enclosed by the rope. | |
// Since the enclosed area will vary according to the shape of the rope, the area method | |
// accepts a formula for calculating the area based on a specified shape. | |
// However with fat arrows, the context is static and tight-bound so 'this' is wrong and | |
// 'call' is useless |
This file contains 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
//the old way | |
var a= { | |
aa: function() { | |
return this; | |
} | |
} | |
a.aa(); //a :) |
This file contains 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
So there we were at the Red Drum, a tableful of beers a few that is and all the gangs cutting in and out, paying a dollar quarter at the door, the little hip-pretending weasel there taking tickets, Paddy Cordavan floating in as prophesied (a big tall blond brakeman type subterranean from Eastern Washington cowboy-looking in jeans coming in to a wild generation party all smoky and mad and I yelled, "Paddy Cordavan?" and "Yeah?" and he'd come over)--all sitting together, interesting groups at various tables, Julien, Roxanne (a woman of 25 prophesying the future style of America with short almost crewcut but with curls black snaky hair, snaky walk, pale pale junky anemic face and we say junky when once Dostoevski would have said what? if not ascetic but saintly? but not in the least? but the cold pale booster face of the cold blue girl and wearing a man's white shirt but with the cuffs undone untied at the buttons so I remember her leaning over talking to someone after having been slinked across the floor with f |
This file contains 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
/////////////////////////// | |
// ES6 original | |
//////////////////////////// | |
class A extends B { | |
constructor(x) { | |
this.x = x; | |
} | |
b() {return this.x}; | |
} |
This file contains 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
/* | |
sayIt accepts an unlimited number of chaining calls, each passing a word. When it's finally called | |
without arguments, all the passed words are printed in order | |
sayIt('have')('you')('got')('any')('fish')('fingers?')(); -> | |
"have you got any fish fingers?" | |
A regular implementaion would go sthg like this | |
function sayIt(firstWord) { |