SlideShare a Scribd company logo
1 of 11
Download to read offline
TYPE RECOGNITION
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;
};
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);
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;
};
var extendWithName = function (object, name) {
    if (typeof object == "object") {
        object.name = name;
    }
};
extendWithName(null, "null");

var a = function () {};
extendWithName(a, "function");
WHAT IS YOUR TYPE?
ARE YOU AN OBJECT?
ARE YOU A NUMBER?
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;
};
THANK YOU

More Related Content

Viewers also liked

Writing Identification Tests
Writing Identification TestsWriting Identification Tests
Writing Identification Testsdessandrea
 
The Power of Employee Appreciation. 5 Best Practices in Employee Recognition.
The Power of Employee Appreciation. 5 Best Practices in Employee Recognition.The Power of Employee Appreciation. 5 Best Practices in Employee Recognition.
The Power of Employee Appreciation. 5 Best Practices in Employee Recognition.Sage HR
 
Test and some test types (ev elt)
Test and some test types (ev elt)Test and some test types (ev elt)
Test and some test types (ev elt)theryszard
 
Rewards & recognition
Rewards & recognitionRewards & recognition
Rewards & recognitionAnita Kumari
 
sample test questionnaire in Biological Science
sample test questionnaire in Biological Science sample test questionnaire in Biological Science
sample test questionnaire in Biological Science Victor F. Melitante Jr.
 
Rewards And Recognition
Rewards And RecognitionRewards And Recognition
Rewards And Recognitionrajeevgupta
 
Recognition - International Law
Recognition - International LawRecognition - International Law
Recognition - International LawA K DAS's | Law
 
reward-systems
reward-systemsreward-systems
reward-systemsprashj_04
 
Human Resource Management: Reward and compensation
Human Resource Management: Reward and compensationHuman Resource Management: Reward and compensation
Human Resource Management: Reward and compensationReefear Ajang
 

Viewers also liked (14)

Writing Identification Tests
Writing Identification TestsWriting Identification Tests
Writing Identification Tests
 
The Power of Employee Appreciation. 5 Best Practices in Employee Recognition.
The Power of Employee Appreciation. 5 Best Practices in Employee Recognition.The Power of Employee Appreciation. 5 Best Practices in Employee Recognition.
The Power of Employee Appreciation. 5 Best Practices in Employee Recognition.
 
Test and some test types (ev elt)
Test and some test types (ev elt)Test and some test types (ev elt)
Test and some test types (ev elt)
 
Rewards & recognition
Rewards & recognitionRewards & recognition
Rewards & recognition
 
Employee recognition
Employee recognitionEmployee recognition
Employee recognition
 
sample test questionnaire in Biological Science
sample test questionnaire in Biological Science sample test questionnaire in Biological Science
sample test questionnaire in Biological Science
 
Concept of reward and total reward system
Concept of reward and total reward systemConcept of reward and total reward system
Concept of reward and total reward system
 
Gesture recognition
Gesture recognitionGesture recognition
Gesture recognition
 
Types of test
Types of testTypes of test
Types of test
 
Reward Management
Reward ManagementReward Management
Reward Management
 
Rewards And Recognition
Rewards And RecognitionRewards And Recognition
Rewards And Recognition
 
Recognition - International Law
Recognition - International LawRecognition - International Law
Recognition - International Law
 
reward-systems
reward-systemsreward-systems
reward-systems
 
Human Resource Management: Reward and compensation
Human Resource Management: Reward and compensationHuman Resource Management: Reward and compensation
Human Resource Management: Reward and compensation
 

More from Dmitry Baranovskiy (14)

The Origins of Magic
The Origins of MagicThe Origins of Magic
The Origins of Magic
 
Demystifying Prototypes
Demystifying PrototypesDemystifying Prototypes
Demystifying Prototypes
 
Raphaël
RaphaëlRaphaël
Raphaël
 
Raphaël JS Conf
Raphaël JS ConfRaphaël JS Conf
Raphaël JS Conf
 
Obvious Secrets of JavaScript
Obvious Secrets of JavaScriptObvious Secrets of JavaScript
Obvious Secrets of JavaScript
 
Your JavaScript Library
Your JavaScript LibraryYour JavaScript Library
Your JavaScript Library
 
Canvas
CanvasCanvas
Canvas
 
SVG
SVGSVG
SVG
 
Java Script Workshop
Java Script WorkshopJava Script Workshop
Java Script Workshop
 
Raphael
RaphaelRaphael
Raphael
 
Web Vector Graphics
Web Vector GraphicsWeb Vector Graphics
Web Vector Graphics
 
Typography on the Web
Typography on the WebTypography on the Web
Typography on the Web
 
Microformats—the hidden treasure
Microformats—the hidden treasureMicroformats—the hidden treasure
Microformats—the hidden treasure
 
Advanced JavaScript Techniques
Advanced JavaScript TechniquesAdvanced JavaScript Techniques
Advanced JavaScript Techniques
 

Recently uploaded

French Revolution (फ्रेंच राज्यक्रांती)
French Revolution  (फ्रेंच राज्यक्रांती)French Revolution  (फ्रेंच राज्यक्रांती)
French Revolution (फ्रेंच राज्यक्रांती)Shankar Aware
 
TUYỂN TẬP 20 ĐỀ THI KHẢO SÁT HỌC SINH GIỎI MÔN TIẾNG ANH LỚP 6 NĂM 2020 (CÓ Đ...
TUYỂN TẬP 20 ĐỀ THI KHẢO SÁT HỌC SINH GIỎI MÔN TIẾNG ANH LỚP 6 NĂM 2020 (CÓ Đ...TUYỂN TẬP 20 ĐỀ THI KHẢO SÁT HỌC SINH GIỎI MÔN TIẾNG ANH LỚP 6 NĂM 2020 (CÓ Đ...
TUYỂN TẬP 20 ĐỀ THI KHẢO SÁT HỌC SINH GIỎI MÔN TIẾNG ANH LỚP 6 NĂM 2020 (CÓ Đ...Nguyen Thanh Tu Collection
 
أَسَانِيدُ كُتُبِ وَأُصُولِ النَّشْرِ لِابْنِ الْجَزَرِيِّ وَالْوَصْلُ بِهَا....
أَسَانِيدُ كُتُبِ وَأُصُولِ النَّشْرِ لِابْنِ الْجَزَرِيِّ وَالْوَصْلُ بِهَا....أَسَانِيدُ كُتُبِ وَأُصُولِ النَّشْرِ لِابْنِ الْجَزَرِيِّ وَالْوَصْلُ بِهَا....
أَسَانِيدُ كُتُبِ وَأُصُولِ النَّشْرِ لِابْنِ الْجَزَرِيِّ وَالْوَصْلُ بِهَا....سمير بسيوني
 
TUYỂN TẬP 25 ĐỀ THI HỌC SINH GIỎI MÔN TIẾNG ANH LỚP 6 NĂM 2023 CÓ ĐÁP ÁN (SƯU...
TUYỂN TẬP 25 ĐỀ THI HỌC SINH GIỎI MÔN TIẾNG ANH LỚP 6 NĂM 2023 CÓ ĐÁP ÁN (SƯU...TUYỂN TẬP 25 ĐỀ THI HỌC SINH GIỎI MÔN TIẾNG ANH LỚP 6 NĂM 2023 CÓ ĐÁP ÁN (SƯU...
TUYỂN TẬP 25 ĐỀ THI HỌC SINH GIỎI MÔN TIẾNG ANH LỚP 6 NĂM 2023 CÓ ĐÁP ÁN (SƯU...Nguyen Thanh Tu Collection
 
30 ĐỀ PHÁT TRIỂN THEO CẤU TRÚC ĐỀ MINH HỌA BGD NGÀY 22-3-2024 KỲ THI TỐT NGHI...
30 ĐỀ PHÁT TRIỂN THEO CẤU TRÚC ĐỀ MINH HỌA BGD NGÀY 22-3-2024 KỲ THI TỐT NGHI...30 ĐỀ PHÁT TRIỂN THEO CẤU TRÚC ĐỀ MINH HỌA BGD NGÀY 22-3-2024 KỲ THI TỐT NGHI...
30 ĐỀ PHÁT TRIỂN THEO CẤU TRÚC ĐỀ MINH HỌA BGD NGÀY 22-3-2024 KỲ THI TỐT NGHI...Nguyen Thanh Tu Collection
 

Recently uploaded (6)

French Revolution (फ्रेंच राज्यक्रांती)
French Revolution  (फ्रेंच राज्यक्रांती)French Revolution  (फ्रेंच राज्यक्रांती)
French Revolution (फ्रेंच राज्यक्रांती)
 
TUYỂN TẬP 20 ĐỀ THI KHẢO SÁT HỌC SINH GIỎI MÔN TIẾNG ANH LỚP 6 NĂM 2020 (CÓ Đ...
TUYỂN TẬP 20 ĐỀ THI KHẢO SÁT HỌC SINH GIỎI MÔN TIẾNG ANH LỚP 6 NĂM 2020 (CÓ Đ...TUYỂN TẬP 20 ĐỀ THI KHẢO SÁT HỌC SINH GIỎI MÔN TIẾNG ANH LỚP 6 NĂM 2020 (CÓ Đ...
TUYỂN TẬP 20 ĐỀ THI KHẢO SÁT HỌC SINH GIỎI MÔN TIẾNG ANH LỚP 6 NĂM 2020 (CÓ Đ...
 
أَسَانِيدُ كُتُبِ وَأُصُولِ النَّشْرِ لِابْنِ الْجَزَرِيِّ وَالْوَصْلُ بِهَا....
أَسَانِيدُ كُتُبِ وَأُصُولِ النَّشْرِ لِابْنِ الْجَزَرِيِّ وَالْوَصْلُ بِهَا....أَسَانِيدُ كُتُبِ وَأُصُولِ النَّشْرِ لِابْنِ الْجَزَرِيِّ وَالْوَصْلُ بِهَا....
أَسَانِيدُ كُتُبِ وَأُصُولِ النَّشْرِ لِابْنِ الْجَزَرِيِّ وَالْوَصْلُ بِهَا....
 
TUYỂN TẬP 25 ĐỀ THI HỌC SINH GIỎI MÔN TIẾNG ANH LỚP 6 NĂM 2023 CÓ ĐÁP ÁN (SƯU...
TUYỂN TẬP 25 ĐỀ THI HỌC SINH GIỎI MÔN TIẾNG ANH LỚP 6 NĂM 2023 CÓ ĐÁP ÁN (SƯU...TUYỂN TẬP 25 ĐỀ THI HỌC SINH GIỎI MÔN TIẾNG ANH LỚP 6 NĂM 2023 CÓ ĐÁP ÁN (SƯU...
TUYỂN TẬP 25 ĐỀ THI HỌC SINH GIỎI MÔN TIẾNG ANH LỚP 6 NĂM 2023 CÓ ĐÁP ÁN (SƯU...
 
LAR MARIA MÃE DE ÁFRICA .
LAR MARIA MÃE DE ÁFRICA                 .LAR MARIA MÃE DE ÁFRICA                 .
LAR MARIA MÃE DE ÁFRICA .
 
30 ĐỀ PHÁT TRIỂN THEO CẤU TRÚC ĐỀ MINH HỌA BGD NGÀY 22-3-2024 KỲ THI TỐT NGHI...
30 ĐỀ PHÁT TRIỂN THEO CẤU TRÚC ĐỀ MINH HỌA BGD NGÀY 22-3-2024 KỲ THI TỐT NGHI...30 ĐỀ PHÁT TRIỂN THEO CẤU TRÚC ĐỀ MINH HỌA BGD NGÀY 22-3-2024 KỲ THI TỐT NGHI...
30 ĐỀ PHÁT TRIỂN THEO CẤU TRÚC ĐỀ MINH HỌA BGD NGÀY 22-3-2024 KỲ THI TỐT NGHI...
 

Type Recognition

  • 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. 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. 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. var extendWithName = function (object, name) { if (typeof object == "object") { object.name = name; } };
  • 6. extendWithName(null, "null"); var a = function () {}; extendWithName(a, "function");
  • 7. WHAT IS YOUR TYPE?
  • 8. ARE YOU AN OBJECT?
  • 9. ARE YOU A NUMBER?
  • 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; };