problema alcance

In this example below you will see how to do a problema alcance with some HTML / CSS and Javascript

This awesome code was written by 0utKast, you can see more from this user in the personal repository.
You can find the original code on
Copyright 0utKast ©
  • HTML
<!DOCTYPE html>
<html lang="en" >

  <meta charset="UTF-8">
  <title>problema alcance</title>


<p>Problema alcance.</p>
<p id="demo"></p>
function retrasarSaludo(nombre) {
    this.nombre = nombre;
    this.hola = function () {
        setTimeout(function () {
            alert('Hola ' + this.nombre);
        }, 0);
var saludo = new retrasarSaludo('Pedro');
saludo.hola(); // alerta 'Hola undefined'