I'm sure for most of you it's the old news, but here's a short reminder anyway:
song = {
handleEvent: function (event) {
switch (event.type) {
case: "click":
console.log(this.name);
var reverseString = function ( subj ) { | |
var helper = subj.split (''), | |
i = 0, k = helper.length, len = helper.length / 2, | |
swap | |
for ( ; i < len; i += 1, k -= 1 ) { | |
swap = helper[ k ]; | |
helper[ k ] = helper[ i ]; | |
helper[ i ] = swap; | |
} |
// Render JavaScript template (from http://git.io/B7KxZg DoAT Touchy) | |
// | |
// You can place your template in a script tag with type other than "text/javascript" | |
// such as "text/html", like this: | |
// <script type="text/html" id="item-template"> | |
// <li id="{{id}}"> | |
// <p>{{content}}</p> | |
// </li> | |
// You'd then render your template like this: | |
// var itemTemplate = document.getElementById('item-template').innerHTML; |
!function () { | |
// helper to set prototype chain up | |
var Constructor = function () {}; | |
Constructor.prototype = Array.prototype; | |
var NotRealArray = function () {}; | |
// inherit from Array | |
NotRealArray.prototype = new Constructor; |
// Helper function to correctly set up the prototype chain, for subclasses. | |
// Similar to `goog.inherits`, but uses a hash of prototype properties and | |
// class properties to be extended. | |
var inherits = function(parent, protoProps, staticProps) { | |
var child; | |
// The constructor function for the new subclass is either defined by you | |
// (the "constructor" property in your `extend` definition), or defaulted | |
// by us to simply call the parent's constructor. | |
if (protoProps && protoProps.hasOwnProperty('constructor')) { |
// naïve bind implementation | |
Function.prototype.bind = function () { | |
var obj = arguments[0], args = [].slice.call(arguments, 1); | |
return function () { | |
this.apply( | |
obj, | |
[].concat.call(args, [].slice.call(arguments)) | |
); | |
} |
function () {} |
var down = "touchup" in window ? "touchup" : "click"; | |
var abstractView = Backbone.View.extend({ | |
// we don't want both click and touch handlers | |
// delegated on touch-enabled devices | |
events: function () { | |
"click .toggler" : "foo", | |
"touchup .toggler" : "bar" | |
}, | |
initialize: function () { |
In the spirit of Railsgirls Berlin, we want to start a programming education group for JavaScript. We need your help to get all the coaching done.
If you are interested in coaching JavaScript, fork this gist and add yourself or leave your contact data in a comment:
// An example from http://matt.might.net/articles/implementation-of-recursive-fixed-point-y-combinator-in-javascript-for-memoization/ | |
var Y = function (F) { | |
return (function (x) { | |
return F(function (y) { return (x(x))(y);}); | |
}(function (x) { | |
return F(function (y) { return (x(x))(y);}); | |
})); | |
}; |