Page 159 - CITS - CSA - TP (Volume 1) - Hindi
P. 159

कंप्यूटर सॉफ्टवेयर एप्लीकेशन- CITS



           अ ास 40 : जावा    म  ऑ े  बनाना और उनका उपयोग करना (Creating and using Objects
                              in JavaScript)


            उ े
           इस अ ास के  अंत म  आप यह कर सक  गे
           •  ऑ े  बनाएँ
           •  डॉ ूम ट ऑ े  मॉडल का उपयोग कर ।

           आव कताएं  (Requirements)
           औजार/साम ी (Tools/Materials)

           •  लेटे  कॉ  फ़गरेशन वाला डे टॉप / लैपटॉप
           •  टे  एिडटर
           •  वेब  ाउज़र

            ि या (Procedure)

           टा  1: ऑ े  बनाना
           I   ऑ े  िलटरल नोटेशन का उपयोग करना
              1  टे  एिडटर ओपन कर

              2  िन िल खत कोड िलख
                 <html >
                 <head>
                 <title> Object Literal Notation </title>

                 </head>
                 <body>
                 <script>
                 // Creating an object using object literal notation

                 var person = {
                 firstName: “John”,
                 lastName: “Doe”,
                 age: 30,
                 fullName: function() {
                 return this.firstName + “ “ + this.lastName;
                 }

                 };
                 // Accessing object properties and methods
                 console.log(person.firstName); // Output: John
                 console.log(person.lastName); // Output: Doe
                 console.log(person.age); // Output: 30
                 console.log(person.fullName()); // Output: John Doe
                 </script>
                 </body>
                 </html>



                                                           143
   154   155   156   157   158   159   160   161   162   163   164