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 October 28, 2011 00:18
Q14 - The interval dance (answer)
setTimeout(function go() {
$.get('http://javascriptquiz.com/api/q14', function(response) {
//logic is not important to the demo
setTimeout(go, 30000);
});
}, 30000);
@aaronpowell
aaronpowell / fiddle.js
Created October 27, 2011 03:17
Xamlizer - a way to implement INotifyPropertyChang* in JavaScript!
var xamlizer = (function() {
'use strict';
var __hasOwn = Object.prototype.hasOwnProperty;
var propSkeleton = function() {
this.enumerable = true;
this.configurable = true;
//this.writable = true;
};
@aaronpowell
aaronpowell / fiddle.js
Created October 24, 2011 00:40
Q14 - The interval dance
setInterval(function() {
$.get('http://javascriptquiz.com/api/q14', function(response) {
//logic is not important to the demo
});
}, 30000);
@aaronpowell
aaronpowell / fiddle.js
Created October 16, 2011 21:54
Q13 - Why is that right?
if(a == !a) {
console.log('a is equal to its inequality!');
} else {
console.log('a isn\'t equal to its inequality');
}
@aaronpowell
aaronpowell / fiddle.js
Created September 23, 2011 23:21
Q12 - Operator please
var a = function() {
return 1;
};
var b = function() {
return a(), 2;
};
@aaronpowell
aaronpowell / fiddle.js
Created September 23, 2011 07:14
Q11 - Spot the bug
var reader = {
setup: function() {
this.getData();
},
getData: function() {
$.ajax({
url: 'http://api.ihackernews.com/page?format=jsonp',
dataType: 'jsonp',
success: function(data) {
this.showData(data);
@aaronpowell
aaronpowell / fiddle.js
Created September 19, 2011 04:50
Q10 - Who shot first?
var whoShotFirst = function () {
var firstShooter;
setTimeout(function() {
if(!firstShooter)
firstShooter = 'Han';
}, 1);
setTimeout(function() {
if(!firstShooter)
@aaronpowell
aaronpowell / knockout.validatedObservable.js
Created September 13, 2011 05:07
Validated observables in KnockousJS
ko.validatedObservable = function (initialValue, validationFunction) {
var latestValue = initialValue;
function observable() {
if (arguments.length > 0) {
// Write
// Ignore writes if the value hasn't changed
if (((!observable['equalityComparer']) || !observable['equalityComparer'](latestValue, arguments[0]))) {
if (validationFunction.call(null, arguments[0])) {
@aaronpowell
aaronpowell / fiddle.js
Created September 11, 2011 23:00
Q9 - It doesn't add up
var a = [1,2,3],
b = [4],
c = [5, 6];
console.log(a + b + c);
@aaronpowell
aaronpowell / fiddle.js
Created August 31, 2011 06:15
Q8 - Truth is stranger than fiction
var hasVideoSupport = function(o) {
if(!o.canPlayType) {
return false;
} else {
return true;
}
};