Skip to content

Instantly share code, notes, and snippets.

View zykadelic's full-sized avatar

Andreas Fransson zykadelic

View GitHub Profile
@zykadelic
zykadelic / object.except.js
Last active August 29, 2015 14:03
Cleans up the object from the given arguments
if(typeof Object.prototype.except !== 'function'){
Object.prototype.except = function(){
for(var i = 0, j = arguments.length; i < j; i++){
if(this.hasOwnProperty(arguments[i])){
delete this[arguments[i]];
}
}
return this;
}
}
@zykadelic
zykadelic / object.slice.js
Created June 27, 2014 11:39
Returns a new object with only the keys provided as arguments, leaves old object intact
if(!Object.prototype.slice){
Object.prototype.slice = function(){
var returnObj = {};
for(var i = 0, j = arguments.length; i < j; i++){
if(this.hasOwnProperty(arguments[i])){
returnObj[arguments[i]] = this[arguments[i]];
}
}
return returnObj;
}