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

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




              3   ो ाम को .html फ़ाइल के   प म  सेव कर

              4  वेब  ाउज़र से html फ़ाइल ओपन कर
              5   ाउज़र कं सोल टैब पर जाएँ  और आउटपुट की पुि  कर ।

















           III   ास  का उपयोग करना  (Using Classes)
              1  टे  एिडटर ओपन कर

              2  िन िल खत कोड िलख

                 <html >
                 <head>
                 <title> Classes </title>

                 </head>
                 <body>

                 <script>
                 // ES6 class for creating person objects
                 class Person {

                 constructor(firstName, lastName, age) {
                 this.firstName = firstName;
                 this.lastName = lastName;

                 this.age = age;
                 }
                 fullName() {

                 return this.firstName + “ “ + this.lastName;
                 }

                 }
                 // Creating a new instance of Person
                 let person2 = new Person(“Jane”, “Smith”, 25);

                 // Accessing object properties and methods
                 console.log(person2.firstName); // Output: Jane
                 console.log(person2.lastName); // Output: Smith

                 console.log(person2.age); // Output: 25



                                                           145

                                     CITS : IT & ITES - कं  ूटर सॉ वेयर ए ीके शन - अ ास 40
   156   157   158   159   160   161   162   163   164   165   166