Ruby developers will find CoffeeScript to be a great alternative to JavaScript, with a lot of familiar language features. This talk introduces CoffeeScript by starting with JavaScript, then ripping out the cruft and ceremony. (WindyCityRails 2011)
{ var tmp = ary1; ary1 = ary2; ary2 = tmp; } var out = []; for (var i=0; i<ary1.length; ++i) { var val = ary1[i]; if (ary2.indexOf(val) >= 0) out.push(val); } return out; } Whirlwind Tour
{ var tmp = ary1; ary1 = ary2; ary2 = tmp; } var out = []; for (var i=0; i<ary1.length; ++i) { var val = ary1[i]; if (ary2.indexOf(val) >= 0) out.push(val); } return out; } Whirlwind Tour
{ var tmp = ary1; ary1 = ary2; ary2 = tmp; } var out = []; for (var i=0; i<ary1.length; ++i) { var val = ary1[i]; if (ary2.indexOf(val) >= 0) out.push(val); } return out; } Whirlwind Tour X X X X X
{ var tmp = ary1; ary1 = ary2; ary2 = tmp; } var out = []; for (var i=0; i<ary1.length; ++i) { var val = ary1[i]; if (ary2.indexOf(val) >= 0) out.push(val); } return out; } Whirlwind Tour X X X X X X X
{ var tmp = ary1; ary1 = ary2; ary2 = tmp; } var out = []; for (var i=0; i<ary1.length; ++i) { var val = ary1[i]; if (ary2.indexOf(val) >= 0) out.push(val); } return out; } Whirlwind Tour X X X X X X X X X X X X X
{ var tmp = ary1; ary1 = ary2; ary2 = tmp; } var out = []; for (var i=0; i<ary1.length; ++i) { var val = ary1[i]; if (ary2.indexOf(val) >= 0) out.push(val); } return out; } Whirlwind Tour X X X X X X X X X X X X X X X X X X
$('#person_name').text(@person.full_name) person = # loaded from server controller = new PersonController(person) $('button').click controller.display_person # FAIL!
$('#person_name').text(@person.full_name) => person = # loaded from server controller = new PersonController(person) $('button').click controller.display_person # FAIL!