typeof and instanceof Operator in JavaScript

Full Stack Web Development Courses with Real-time projects Start Now!!

Program 1

<html>
    <head>
        <title>typeof and instance of operator</title>
        <script type="text/javascript">
            /* 
              /* 
               JavaScript Data Type
            number
            boolean
            bigint
            string
            symbol
            null
            undefined
           */
                
                 document.writeln("<center>")
                    document.writeln("<h1>")   
                    let a=123
                    let b=123.23
                    let c=true
                    let d=123n
                    // document.writeln(typeof(a))  // number
                    // document.writeln("<br>"+typeof(b))  //number
                    // document.writeln("<br>"+typeof(c)) //boolean
                    // document.writeln("<br>"+typeof(d)) // biging
                    // let s="Hello"
                    // document.writeln("<br>"+typeof(s)) 
                    // document.writeln("<br>"+typeof(Symbol())) 
                    // document.writeln("<br>"+typeof(null)) //Object
                    // document.writeln("<br>"+typeof(undefined)) //undefined
                    // document.writeln("<br>"+ null==undefined)
                    //document.writeln("<br>"+typeof(x))  
                    // document.writeln("<br>"+ typeof(10+10))  //number
                    // document.writeln("<br>"+ typeof(10+"10"))  //string
                    // document.writeln("<br>"+ typeof("10"+"10")) //string 
                    // document.writeln("<br>"+ typeof(10+true))  //number
                    // document.writeln("<br>"+ typeof(false+10))  //number
                    // document.writeln("<br>"+ typeof(true+true))  //number
                    // document.writeln("<br>"+ typeof("10"+true))  //string
                    // document.writeln("<br>"+ typeof(null+null))//number
                    // document.writeln("<br>"+ typeof(10-10))//number 
                    // document.writeln("<br>"+ typeof("10"-10))//number 
                    // document.writeln("<br>"+ typeof("10"-"10"))//number
                        // let myar=[1,2,3,4,5,6,7,8]
                        // document.writeln("<br>"+ typeof(myar))//number
                        // let myset=new Set(["Pune","Indore","Delhi"])
                        // document.writeln("<br>"+ typeof(myset))//number
                        //  let mymap=new Map([[1,"Indore"],[2,"Pune"]])   
                        //  document.writeln("<br>"+ typeof(mymap))//number
                        // function display()
                        // {}
                        // document.writeln("<br>"+ typeof(display))//number

                        // instanceof

                        const myset=new Set(["Indore","Pune","Bhopal","Delhi","Ujjain",123,true,12.55])
                         document.writeln(myset instanceof Set)
                         S= new String("Hello")                
                         document.writeln(S instanceof String)             




                    document.writeln("</h1>")
                document.writeln("</center>")   
         </script>
    </head>
    <body>
        <center>
              
         </center>   
    
    </body>
</html>

 

Did we exceed your expectations?
If Yes, share your valuable feedback on Google

courses
Image

DataFlair Team

DataFlair Team provides high-impact content on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. We make complex concepts easy to grasp, helping learners of all levels succeed in their tech careers.

Leave a Reply

Your email address will not be published. Required fields are marked *