Set Object in JavaScript

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

Program 1

<html>
    <head>
        <title>Set Object Methods</title>
        <script type="text/javascript">
                   document.writeln("<center>")
                    document.writeln("<h2>")
                    
                    const myset=new Set(["Vishal","Rajesh","Vivek","Harish","Montu","Pintu",true,123,34.55])
                    
                      //myitr=myset.values()
                    //   for(let x of myitr)
                    //   {
                    //     document.writeln("<br>"+x)    
                    //   }
                    //   let s=prompt("Enter value for search: ")
                    //    document.writeln("<br>--------------------------------") 
                    //    document.writeln(myset.delete(s))

                    //    myitr=myset.values()
                    //    for(let x of myitr)
                    //   {
                    //     document.writeln("<br>"+x)    
                    //   }

                //       let s=prompt("Enter value for search: ")
                //     //   document.writeln("<br>"+myset.has(s))
                //     if(myset.has(s))
                //     document.writeln("<br>Searching success")
                // else
                //   document.writeln("<br>Searching not success") 


                    // const myset=new Set([])
                    // document.writeln(myset.size)
                    // for(let i=1;i<=5;i++)
                    // {
                    // let data=prompt("Enter value")
                    // myset.add(data)
                    // }
                    // document.writeln(myset.size)
                    
                    //   myitr=myset.values()
                    //   for(let x of myitr)
                    //   {
                    //     document.writeln("<br>"+x)    
                    //   }


                    // const myset=new Set(["Vishal","Rajesh","Vivek","Harish","Montu","Pintu",true,123,34.55])
                    //   myitr=myset.values()
                    //   for(let x of myitr)
                    //   {
                    //     document.writeln("<br>"+x)    
                    //   }
                    //   myitr=myset.keys()
                    //   for(let x of myitr)
                    //   {
                    //     document.writeln("<br>"+x)    
                    //   }

                    // myset.forEach(element => 
                    // {
                    //    document.writeln("<br>"+element)    
                    // });
                //     myset.forEach(function(value)
                //     {
                //         document.writeln("<br>"+value)    
                //     }
                // )

                    document.writeln("<h2>")
                   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 *