Site icon DataFlair

JavaScript typeof and instanceof Operator

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
           */
              let a=123
              let b=123.45
              let c=1234n
              let d=true
              let e="Hello"
             document.writeln("<center>")
            document.writeln("<h2>")
                // document.writeln(typeof a)
                // document.writeln("<br>"+typeof b)
                // document.writeln("<br>"+typeof c)
                // document.writeln("<br>"+typeof d)
                // document.writeln("<br>"+typeof e)
                // document.writeln("<br>"+typeof null)
                // document.writeln("<br>"+typeof Symbol())
                // document.writeln("<br>"+typeof undefined)
                // document.writeln("<br>"+null===undefined)
                // 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))  
                // document.writeln("<br>"+typeof (true+false))  
                // document.writeln("<br>"+typeof (10+12.44))  
               // document.writeln("<br>"+typeof ("10"-"10"))
                //    let ar=new Array([10,20,30,40] )
                //    document.writeln("<br>"+typeof (ar))
                // function display()
                // {
                //     document.writeln("Hello")
                // }
                // document.writeln("<br>"+typeof (display))
                
                
                
                               
                const myset=new Set(["Indore","Pune","Bhopal","Delhi","Ujjain",123,true,12.55])
                
                document.writeln(myset instanceof Set)    
                let s=new String("Hello Friends")
                document.writeln(s instanceof Set)    
                //document.writeln("<br>"+typeof (myset))

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

 

Exit mobile version