Skip to content

Instantly share code, notes, and snippets.

@NrI3
Created July 28, 2017 16:09
Show Gist options
  • Select an option

  • Save NrI3/287b05760fa1eba1b406555b647cf268 to your computer and use it in GitHub Desktop.

Select an option

Save NrI3/287b05760fa1eba1b406555b647cf268 to your computer and use it in GitHub Desktop.
Helper JS
# Constructor
# Muestra la funcion del constructor a la que pertenece dicho objeto
Objetc.consturctor
# Prototype
# Muestra la lista de propiedades y metodos del objeto sin haber sido inicializado
# Toda modificacion que se realice en el objeto se hereda a los objetos que hereden este objeto
#Ejemplo
Object.prototype.testString = "Esto se heredara a cualquier objeto de tipo Object"
var x = new Object();
x.testString
# Modificando las propiedades de HTMLHtmlElement para mostrar children como list
# ya que si intentamos modificar la propiedad directamente nos salta error
# Forma apropiada de definir una propiedad sin llamar a una funcion
HTMLHtmlElement.prototype.__defineGetter__( 'list', function(){ return this.children } )
# Error al definir la misma en forma directa
HTMLHtmlElement.prototype.list = HTMLHtmlElement.prototype.children
# Definirla en forma de funcion
HTMLHtmlElement.prototype.list = function(){ this.list = this.children }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment