Last active
August 29, 2015 14:25
-
-
Save ecasilla/b0d0a2fc445cb27a07ec to your computer and use it in GitHub Desktop.
DOT operator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DOT = function(obj,prop){ | |
if(obj.hasOwnProperty(prop)){ | |
return obj[prop]; | |
}else if(obj.__proto__){ | |
return DOT(obj.__proto__,prop) | |
} | |
} | |
DOTCALL = function(obj,props,args){ | |
var fn = DOT(obj,props); | |
if(fn){ | |
return fn.apply(obj,args); | |
} | |
} | |
NEW = function(constructor,args){ | |
var subject = {}; | |
subject.__proto__ = constructor.prototype; | |
constructor.apply(subject,args); | |
return subject; | |
} | |
INSTANCEOF = function(obj,constructor){ | |
if(obj.__proto__ === constructor.prototype){ | |
return true; | |
}else if(obj.__proto__){ | |
return INSTANCEOF(obj.__proto__,constructor); | |
}else{ | |
return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment