Ver Mensaje Individual
  #12 (permalink)  
Antiguo 05/02/2011, 20:02
Avatar de _cronos2
_cronos2
Colaborador
 
Fecha de Ingreso: junio-2010
Mensajes: 2.062
Antigüedad: 13 años, 10 meses
Puntos: 310
Respuesta: Crear objeto THIS

Cita:
Iniciado por masterpuppet Ver Mensaje
Código Javascript:
Ver original
  1. Function.prototype.bind = function(scope)
  2. {
  3.     var _function = this;  
  4.     return function() {
  5.         return _function.apply(scope, arguments);
  6.     }
  7. }
  8.  
  9. //ej 1
  10. var fn = function(){
  11.     alert(this);
  12. }.bind(objetos);
  13. fn();
  14.  
  15. //ej 2
  16. for(var i in objetos)
  17. {
  18.     (function(){
  19.         alert(this.className);
  20.     }.bind(objetos[i]))();
  21. }
Eeeeeerm... ¿un poco de documentación por favor? XD
__________________
" Getting older’s not been on my plans
but it’s never late, it’s never late enough for me to stay. "
Cigarettes - Russian Red