//Regular Lecture 19: 18 Oct 2022
//Topic 12: //* oops- object oriented programming*// creating object templates // way 2
//2) with ES6 class:
//program example 1
class form7 {
constructor(fn, ln, ag){
this.firstName = fn
this.lastName = ln
this.age = ag
}
}
let mahendra = new form7("mahendra", 'dhoni', 38)
console.log(mahendra)
//program example 2
class form8 {
constructor(fn, ln, ag){
this.firstName = fn
this.lastName = ln
this.age = ag
}
}
let yuvraj = new form8 ("yuvraj", "singh", 39)
console.log(yuvraj)
let virendra = new form8 ("virendra", "sehwag", 42)
console.log(virendra)
//program example 3
class form9 {
constructor(cl,g,sub){
this.class = cl
this.gender = g
this.subject = sub
}
}
let rupesh = new form9 (8, "male", "english")
console.log(rupesh)
let suhas = new form9 (10, "male", "maths")
console.log(suhas)
//program example 4
class form10 {
constructor(fn, ci, st, cn){
this.firstName = fn
this.city = ci
this.state = st
this.country = cn
}
}
let sita = new form10 ("sita", "tuljapur", "MH", "India")
console.log(sita)
let hanumant = new form10 ("hanumant", "surat", "GJ", "India")
console.log(hanumant)
//we can do retrive, addition, update, delete operations with objects created using template
hanumant.age = 30
console.log(hanumant)
sita.age = 25
console.log(sita)
delete hanumant.country
console.log(hanumant)
delete sita.country
console.log(sita)
टिप्पण्या
टिप्पणी पोस्ट करा
आपल्या प्रतिक्रियेबद्दल धन्यवाद ! आम्ही लवकरात लवकर प्रतिक्रियेला उत्तर देण्याचा प्रयत्न करू