From 5b4366cea950cc1098406738c609db71935788c3 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Tue, 6 Jun 2023 19:18:04 +0300 Subject: [PATCH] docs... Signed-off-by: Alex A. Naanou --- js-types-n-oop.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/js-types-n-oop.js b/js-types-n-oop.js index 482ffc8..6ad1646 100755 --- a/js-types-n-oop.js +++ b/js-types-n-oop.js @@ -85,7 +85,7 @@ // Type checking // - + typeof(42) // -> 'number' @@ -95,6 +95,21 @@ // Type cheking // +// Here thesame approach as for simple types is not productive: + + typeof([42]) // -> 'object' + typeof({}) // -> 'object' + +// so a better approach would be to: + + [42] instanceof Array // -> true + +// but since all objects are objects the test can get quite generic (XXX) + + [42] instanceof Object // -> true + {} instanceof Object // -> true + + // Prototypes and inheritance