Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Typeof operator returning undefined for everything but 'strings'

I’m currently learning about the "typeof" operator in JavaScript, but the tutorial I’m following gives me different results than what I’m seeing in my console. Using anything other than ‘strings’ returns undefined. There are a few things I’ve seen about Automatic Semicolon Insertion, but they seem a bit more complicated than my current issue. Sorry, this might sound silly to the veterans, but for some reason I can’t find the answer to the problem.

VS Code Screen Shot

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

you are evaluating code in two different contexts: your module, where your variables exists with a value and in the console where they are undefined, hence the result you see. You can add to typeof in your script directly to see the correct result.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading