Skip to content

Instantly share code, notes, and snippets.

@boton
Created August 23, 2011 01:20
Show Gist options
  • Select an option

  • Save boton/1164067 to your computer and use it in GitHub Desktop.

Select an option

Save boton/1164067 to your computer and use it in GitHub Desktop.
var Autobot = function(nombre){
this.nombre = nombre;
this.timer = +new Date();
};
Autobot.prototype.saludar = function() {
alert('Hola, me llamo '+ this.nombre + '\nTime: ' + (+new Date() - this.timer) + 'ms' );
};
Autobot.prototype.saludoDelay = function(ms){
var that = this;
setTimeout(function(){that.saludar();}, ms);
};
var optimus = new Autobot('Optimus Prime');
optimus.saludoDelay(100);
optimus.saludoDelay(10000);
@boton

boton commented Aug 23, 2011

Copy link
Copy Markdown
Author

@felixzapata a mi me funciono sin problemas ff, chrome, ie8... por lo que lei a posteriori, en ie6 peta pero no me preocupa, aunque vi alguna solución muy sucia almacenado datos en variables globales...

@felixzapata

Copy link
Copy Markdown

estuve probando únicamente en Firefox. Debí dejarme algo para que diera un fallo. Por eso opté por la otra

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment