Skip to content

Instantly share code, notes, and snippets.

@itsgreggreg
Created September 27, 2015 03:11
Show Gist options
  • Save itsgreggreg/27d13e2817a360393b17 to your computer and use it in GitHub Desktop.
Save itsgreggreg/27d13e2817a360393b17 to your computer and use it in GitHub Desktop.
Advanced JS stuff
// Tell me what is going on here:
function oneHitter(name, val){
if(!oneHitter.cache) oneHitter.cache = {};
if(!oneHitter.cache[name]) oneHitter.cache[name] = val
return oneHitter.cache[name];
}
// Tell me what's going on here':
var days = ["sun","mon","tues","wed","thurs","fri","sat"];
function lastElement(arr){
return arr.splice(arr.length -1);
}
var lastDay = lastElement(days);
days.concat(lastDay).length === 8; // <- what does this evaluate to and why?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment