Dati complessi
L' typeofoperatore puo' restituire uno di due tipi complessi: function object L' typeofoperatore restituisce "oggetto" per oggetti, array e null. L' typeofoperatore non restituisce "oggetto" per le funzioni. Esempio typeof {name:'John', age:34} // Returns "object" typeof [1,2,3,4] // Returns "object" (not "array", see note below) typeof null // Returns "object" typeof function myFunc(){} // Returns "function" <!DOCTYPE html> <html> <body> <h2>JavaScript typeof</h2> <p>The typeof operator returns object for both objects, arrays, and null.</p> <p>The typeof operator does not return object for functions.</p> <p id="demo"></p> <script> document.getElementById("demo").innerHTML = typeof {name:'john', age:34} + "<br>" + typeof [1,2,3,4] + "<br>" + typeof null + "<br>" + typeof function myFunc(){}; </script> </body> </html> Ritorna = object object object function |