Se ha denunciado esta presentación.
Utilizamos tu perfil de LinkedIn y tus datos de actividad para personalizar los anuncios y mostrarte publicidad más relevante. Puedes cambiar tus preferencias de publicidad en cualquier momento.

Type Recognition

3.716 visualizaciones

Publicado el

15 min talk about importance of correct type recognition in methods of public APIs.

Not sure does it make any sense without narration, but anyway due to high demand, here it goes.

Publicado en: Educación
  • Inicia sesión para ver los comentarios

Type Recognition

  1. 1. TYPE RECOGNITION
  2. 2. var html = function (value) { if (typeof value == "string") { element.innerHTML = value; } if (typeof value == "function") { element.innerHTML = value(); } if (value == null) { return element.innerHTML; } return element; };
  3. 3. var a = { value: "I am an object", toString: function () { return this.value; } }; var b = new String("I am a string"); alert(a); el.html(a); alert(b); el.html(b);
  4. 4. var html = function (value) { if (typeof value == "function") { element.innerHTML = value(); } else if (value == null) { return element.innerHTML; } else { element.innerHTML = String(value); } return element; };
  5. 5. var extendWithName = function (object, name) { if (typeof object == "object") { object.name = name; } };
  6. 6. extendWithName(null, "null"); var a = function () {}; extendWithName(a, "function");
  7. 7. WHAT IS YOUR TYPE?
  8. 8. ARE YOU AN OBJECT?
  9. 9. ARE YOU A NUMBER?
  10. 10. var is = function (o, type) { type = (type + "").toLowerCase(); return (type == "object" && o === Object(o)) || (type == "undefined" && typeof o == type) || (type == "null" && o == null) || Object.prototype.toString.call(o) .slice(8, -1).toLowerCase() == type; };
  11. 11. THANK YOU

×