Created
March 4, 2014 06:33
-
-
Save crguezl/9341365 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
Efectivamente prototype es inicializado en las functions pero no en los objects: | |
> {}.prototype | |
undefined | |
> function(){}.prototype | |
{} | |
Sin embargo, Object se refiere al constructor: | |
> {}.constructor == Object | |
true | |
> {}.constructor === Object | |
true | |
Así pues todo atributo de Object es heredado por los objetos: | |
> Object.prototype.chuchu = function() { return "chuchu"; } | |
[Function] | |
> {}.chuchu() | |
'chuchu' | |
No es lo mismo Object que Object.constructor: | |
> Object | |
[Function: Object] | |
> Object.constructor | |
[Function: Function] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment