Skip to content

Instantly share code, notes, and snippets.

@crguezl
Created March 4, 2014 06:33
Show Gist options
  • Save crguezl/9341365 to your computer and use it in GitHub Desktop.
Save crguezl/9341365 to your computer and use it in GitHub Desktop.
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