One trick you should know when working with the"typeof"? operator in Javascript

One trick you should know when working with the"typeof" operator in Javascript

JavaScript has 5 different data types that can contain values:

  • string
  • number
  • boolean
  • object
  • function

The "typeof" Operator

You can use the?typeof?operator to find the data type of a JavaScript variable.

Did you know that when a variable is given the value of "null" in javascript, the output turns out as "object"?

See example;

var XYZ = null;        

Notice that our output will display as "object" .

document.write(typeof(XYZ));
        

Output =

 object        

要查看或添加评论,请登录

Solomon Iniodu的更多文章

  • Day 6/25: Mastering Application Security with Amazon Cognito

    Day 6/25: Mastering Application Security with Amazon Cognito

    Today was a deep dive into the world of cloud application security as I explored how to secure web applications using…

  • Bridging Gaps with Local Service Finder: Our Journey from Concept to Completion

    Bridging Gaps with Local Service Finder: Our Journey from Concept to Completion

    At the culmination of our 14-month Software Engineering Program with ALX Cohort 9, our team has proudly developed and…

  • Flyit

    Flyit

    Project Overview Traveling by air can be an exciting experience, but it can also be quite overwhelming. From booking…

  • Some PHP fun-facts

    Some PHP fun-facts

    Overview The term PHP is an acronym for Hypertext Preprocessor. PHP is a server-side scripting language designed…

  • Major Tools You Don't Want to Ignore as a Full Stack Developer in 2022

    Major Tools You Don't Want to Ignore as a Full Stack Developer in 2022

    There are a ton of full-stack developer tools. From IDEs to project management apps, you’ll find a plethora of options…

  • Top 10 Popular Programming Languages And Their Creators

    Top 10 Popular Programming Languages And Their Creators

    Obviously, in the tech space today, we've come to terms with most programming languages. you know what they do, but do…

  • Basics of JavaScript

    Basics of JavaScript

    Overview JavaScript is a programming language that adds interactivity to your website. This happens in games, in the…

  • JavaScript Output

    JavaScript Output

    What is Javascript Output? JavaScript Output defines the ways to display the output of a given code. The process of…

  • JavaScript Tutorial Summary

    JavaScript Tutorial Summary

    This article is a summary of what I learned today (See the published date) about Javascript. The content here is…

  • CSS Variables - The var() Function

    CSS Variables - The var() Function

    One feature that was on CSS wish lists long before it became a standard is CSS Variables, officially referred to as CSS…

    2 条评论

社区洞察

其他会员也浏览了