Skip to content

Instantly share code, notes, and snippets.

@Der-Eddy
Last active May 11, 2016 23:12
Show Gist options
  • Save Der-Eddy/b040c37ebf013f4ce98d9207a0933f2f to your computer and use it in GitHub Desktop.
Save Der-Eddy/b040c37ebf013f4ce98d9207a0933f2f to your computer and use it in GitHub Desktop.
Date.prototype.getWeekNumber = function(){
var d = new Date(+this);
d.setHours(0,0,0);
d.setDate(d.getDate()+4-(d.getDay()||7));
return Math.ceil((((d-new Date(d.getFullYear(),0,1))/8.64e7)+1)/7);
};
Array.prototype.mapProperty = function(property) {
return this.map(function (obj) {
return obj[property];
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment