- Welcome to the Jungle - Guns N' Roses - jungle.asyncjs.com
- JavaScript Garden?
- Special Features
- Hoisting (scope!)
- Closures (and how to get most out of those)
- Prototypes (vs. classes as in Java etc.)
- ???
- Common Problems
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 context, directives; | |
context = { | |
"header": "Colors", | |
"items": [ | |
{"name": "red", "first": true, "url": "#Red"}, | |
{"name": "green", "link": true, "url": "#Green"}, | |
{"name": "blue", "link": true, "url": "#Blue"} | |
], | |
"empty": false |
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 ctx = { | |
name: 'jude' | |
}; | |
var tpl = "hey {{ name }}, don't make it bad"; | |
var res = tpl.replace(/\{\{([a-zA-Z ]*)\}\}/g, function(m, g) { | |
return ctx[g.trim()]; | |
}); | |
console.log(res); |
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
{ | |
"header": "Colors", | |
"items": [ | |
{"name": "red", "first": true, "url": "#Red"}, | |
{"name": "green", "link": true, "url": "#Green"}, | |
{"name": "blue", "link": true, "url": "#Blue"} | |
], | |
"empty": false | |
} |
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
<h1>{{header}}</h1> | |
{{#items}} | |
{{#first}} | |
<li><strong>{{name}}</strong></li> | |
{{/first}} | |
{{#link}} | |
<li><a href="{{url}}">{{name}}</a></li> | |
{{/link}} | |
{{/items}} |
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
h1= header | |
for item in items | |
if item.first | |
li: strong= item.name | |
if item.link | |
li: a(href= item.url)= item.name | |
if empty | |
p The list is empty. |
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 gt = partialize(function(a, b) { | |
return a < b; | |
}, 2); | |
function partialize(fn, amount) { | |
return function() { | |
return partial(fn, arguments); | |
} | |
}; |
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
'use strict'; | |
var Reflux = require('reflux'); | |
var axios = require('axios'); | |
var Actions = Reflux.createActions({ | |
load: { | |
children: ['completed', 'failed'] | |
} | |
}); |
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
type: rating | |
title: JavaScript Color Pickers | |
user: bebraw | |
slug: javascript-color-pickers | |
includes: [nativeColorPicker, colorjoe, Flexi Colorpicker, SimpleColor, ExColor, JavaScript Colorpicker, Farbtastic, mooRainbow, jPicker] | |
body: | | |
If you are building an application that deals with graphics somehow, you are likely going to need a color picker. Fortunately | |
there are quite a few of those available for JavaScript. HTML5 includes `color` input type even. One color picker, aptly | |
named `nativeColorPicker`, provides a shim for Internet Explorer so that you have got all bases covered. Other pickers | |
available are more specialized. |
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(['../common/annotate', '../math/range', '../functional/map', '../operators/gt'], function(annotate, range, map, gt) { | |
function chunk(len, a) { | |
return map(function(k) { | |
return a.slice(k, k + len); | |
}, range(0, a.length, len)); | |
} | |
return annotate(chunk, gt(0), Array); | |
}); |