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
// 1: how could you rewrite the following to make it shorter? | |
if (foo) { | |
bar.doSomething(el); | |
} else { | |
bar.doSomethingElse(el); | |
} | |
bar[foo ? 'doSomething' : 'doSomethingElse'](el); | |
foo ? bar.doSomething(el) : bar.doSomethingElse(el); // prefer this as it reads better to me |
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
// Exercise 2 - Closures | |
// Wrap the following code in a closure and export only the "countdown" function. | |
// Code | |
(function(container) { | |
var index; | |
function log(){ | |
console.log(index); | |
} |
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(window, document, undefined){ | |
// your code here | |
})(this, document); |
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
// 1. Write a class to support the following code: | |
var Person = function(name) { | |
this.name = name; | |
}; | |
var thomas = new Person('Thomas'); | |
var amy = new Person('Amy'); | |
thomas.name; // --> "Thomas" |
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
(* | |
* Google Chrome View Source in MacVim - v0.1 - 3/7/2011 | |
* http://benalman.com/ | |
* | |
* Copyright (c) 2011 "Cowboy" Ben Alman | |
* Dual licensed under the MIT and GPL licenses. | |
* http://benalman.com/about/license/ | |
*) | |
tell application "Google Chrome" |
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
Speakerrate hates me, so I'm giving feedback this way: | |
A difficult topic for a conference like Front Trends as you have a divided public: lots of designers/frontenders and quite a few JavaScript/Backend developers. | |
I thought the talk was well delivered and didn't do the mistake to go into too much detail. It would be over the top for a designer/html person as it talks about REST, streams, etc which are concepts that most designers wouldn't know. | |
I think however that it's the ideal talk for people who are fairly competent frontend JavaScripters and are interested in node.js or backend developers who use a different technology and are thinking on how they could use node.js in their technology stack. | |
All in all: well done! It's the 1st time I heard a talk like this (about a backend technology) at a frontend conference and I applaud you for it! | |
-- | |
Gilles Ruppert |
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 i = 0, l = 100; | |
for (; i < l; i++) { | |
(function(counter) { | |
setTimeout(function() { | |
console.log(counter); | |
}, 0); | |
}(i)); | |
} |
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
// given the data structure below, we want to get: | |
// rows.id and rows.doc._rev. | |
// JSONStream.parse('rows', true, /id|doc/, /(rev)?/) // doesn't work | |
{"total_rows":129,"offset":0,"rows":[ | |
{ "id":"change1_0.6995461115147918" | |
, "key":"change1_0.6995461115147918" | |
, "value":{"rev":"1-e240bae28c7bb3667f02760f6398d508"} | |
, "doc":{ | |
"_id": "change1_0.6995461115147918" |
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
/* Melody | |
* (cleft) 2005 D. Cuartielles for K3 | |
* | |
* This example uses a piezo speaker to play melodies. It sends | |
* a square wave of the appropriate frequency to the piezo, generating | |
* the corresponding tone. | |
* | |
* The calculation of the tones is made following the mathematical | |
* operation: | |
* |
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
// AMD support | |
if (typeof define === 'function' && define.amd) { | |
define(function () { return Cookies; }); | |
// CommonJS and Node.js module support. | |
} else if (typeof exports !== 'undefined') { | |
// Support Node.js specific `module.exports` (which can be a function) | |
if (typeof module != 'undefined' && module.exports) { | |
exports = module.exports = Cookies; | |
} | |
// But always support CommonJS module 1.1.1 spec (`exports` cannot be a function) |
OlderNewer