Skip to content

Instantly share code, notes, and snippets.

View FGasper's full-sized avatar

Felipe Gasper FGasper

View GitHub Profile
@FGasper
FGasper / object_gave.js
Created November 9, 2011 14:13
Object.gave, an improvement on hasOwnProperty() checks in for..in loops
var HOP = Object.prototype.hasOwnProperty.call.bind(Object.prototype.hasOwnProperty);
//Checks the prototype chain to see if the "giver" "gave" the "key" to the "obj".
Object.gave = function(giver,key,obj) {
//If there are 2 arguments instead of 3, use the Function.prototype method.
if (arguments.length === 2) {
Function.prototype.gave.apply(this,arguments);
}
var last_prototype;