Skip to content

Instantly share code, notes, and snippets.

View aaronpowell's full-sized avatar
😶‍🌫️

Aaron Powell aaronpowell

😶‍🌫️
View GitHub Profile
@aaronpowell
aaronpowell / fiddle.js
Created August 29, 2011 00:35
Detect marquee
Modernizr.addTest('marquee', function() {
return typeof document.createElement('marquee').stop === 'function';
});
Modernizr.load({
test: Modernizr.marquee,
nope: '/path/to/marquee.js'
});
@aaronpowell
aaronpowell / fiddle.js
Created August 22, 2011 23:10
Q7 - Curiouser and Curiouser
var sayColor = function (name) {
color = name();
return "Red" + color;
}
(function () {
return "Green";
})();
@aaronpowell
aaronpowell / api.js
Created August 14, 2011 22:52
Q6 - What's old is new
var Person = function(name) {
this.name = name;
}
Person.prototype.sayHello = function() {
console.log('Hello, my name is ' + this.name);
}
amplify.request.define('get-hole-scores', 'ajax', {
url: '/game/scores/{mode}/{id}',
dataType: 'json',
type: 'GET',
cache: 1000,
decoder: function (data, status, xhr, success, error) {
for (var i = 0, il = data.length; i < il; i++) {
data[i].CompletedAt = new Date(parseInt(data[i].CompletedAt.match(dateRegex)[1], 10));
data[i].completionDate = formatDate(data[i].CompletedAt);
}
@aaronpowell
aaronpowell / fiddle.js
Created August 8, 2011 03:15
Q5 - It's all how you type?
function x() {
console.log(typeof this);
return this;
}
console.log(x.call(2) === 2);
@aaronpowell
aaronpowell / fiddle.js
Created August 1, 2011 02:41
Q4 - Who's the owner?
function Person(name, age) {
this.name = name;
this.age = age;
};
function Employee(name, age, company, jobTitle) {
Person.call(this, company, jobTitle);
this.company = company;
this.jobTitle = jobTitle;
}
@aaronpowell
aaronpowell / fiddle.js
Created July 25, 2011 01:33
Q3 - To array or not to array?
var array = ???
function print(x) {
var s = '';
for(var i = 0, il = x.length; i < il; i++) {
s += (' ' + x[i]);
}
console.log(s);
@aaronpowell
aaronpowell / fiddle.js
Created July 22, 2011 04:18
js function trick
foo();
var foo = function() {
console.log('I\'m fooing');
};
@aaronpowell
aaronpowell / fiddle.js
Created July 17, 2011 23:31
Q2 - Does it run?
doStuff();
var stuff = 24;
function doStuff() {
stuff = 42;
};
console.log(stuff);
@aaronpowell
aaronpowell / q1.js
Created July 11, 2011 01:02
Q1 - Truth about False
var a = 1,
b = 'hello',
c = 0,
d = true,
e;
e = a && b && c && d;
console.log(e);