Created
August 23, 2011 01:20
-
-
Save boton/1164067 to your computer and use it in GitHub Desktop.
#gejs - day04 [exercise 5] - http://gejs.jottit.com/reuni%C3%B3n_4%3A_2011.08.25
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
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); |
@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...
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
Pues fíjate que probé esta solución y no me funcionó... cosa que me extrañó