“classe en javascript” Réponses codées

classe en javascript

class Students {
    name;
    address;
    schoolName = "Morning Sun School";
    constructor(name,address,fatherName){
        this.name = name;
        this.address = address;
        this.fatherName = fatherName;
    }
}
const olivia = new Students("Olivia", "USA","James");
const emma = new Students("Emma", "UK", "alex");
console.log(olivia);
console.log(emma);

// Output of Olivia
Students {
    name: 'Olivia',
    address: 'USA',
    schoolName: 'Morning Sun School',
    fatherName: 'James'
  }
// Output of Emma
  Students {
    name: 'Emma',
    address: 'UK',
    schoolName: 'Morning Sun School',
    fatherName: 'alex'
  }
Ariful Islam Adil(Code Lover)

classe en javascript


class Students {
    name;
    address;
    schoolName = "Morning Sun School";
    constructor(name,address,fatherName){
        this.name = name;
        this.address = address;
        this.fatherName = fatherName;
    }
    raceCompetition(){
        console.log(this.name, "start to run")
    }
}
const olivia = new Students("Olivia", "USA","James");
const emma = new Students("Emma", "UK", "alex");

console.log(olivia);
olivia.raceCompetition()

console.log(emma);
emma.raceCompetition()

// output of olivia
Students {
  name: 'Olivia',
  address: 'USA',
  schoolName: 'Morning Sun School',
  fatherName: 'James'
}
Olivia start to run

// output of Emma
Students {
  name: 'Emma',
  address: 'UK',
  schoolName: 'Morning Sun School',
  fatherName: 'alex'
}
Emma start to run
Ariful Islam Adil(Code Lover)

classe en javascript


class Students {
    name;
    address;
    schoolName = "Morning Sun School";
    constructor(name,address,fatherName){
        this.name = name;
        this.address = address;
        this.fatherName = fatherName;
    }
    raceCompetition(){
        console.log(this.name, "start to run")
    }
}
const olivia = new Students("Olivia", "USA","James");
const emma = new Students("Emma", "UK", "alex");

console.log(olivia);
olivia.raceCompetition()

console.log(emma);
emma.raceCompetition()

// output of olivia
Students {
  name: 'Olivia',
  address: 'USA',
  schoolName: 'Morning Sun School',
  fatherName: 'James'
}
Olivia start to run

// output of Emma
Students {
  name: 'Emma',
  address: 'UK',
  schoolName: 'Morning Sun School',
  fatherName: 'alex'
}
Emma start to run
Ariful Islam Adil(Code Lover)

classe en javascript

/*
A class is a function of a factory that will be used to create many objects,
but no code will be duplicated in creating each object. In other words, 
the code will be written only once, using that code we can create a lot of 
objects again and again.
*/

//Class
class Person{
    constructor(){
        this.name = 'Bill Gates';
    }
}
var person1 = new Person();
console.log(person1.name); //Bill Gates
Tiny Coders

classe en javascript

class Support {
    name;
    designation;
    address;
    constructor(name, designation, address) {
        this.name = name;
        this.designation = designation;
        this.address = address;
    }
    startSession() {
        console.log("start a support session");
    }
}

const abraham = new Support("Abraham", "Web developer", "US");
console.log(abraham);
//output:
/* Support {
    name: 'Abraham',
    designation: 'Web developer',
    address: 'US'
  } */
Ariful Islam Adil(Code Lover)

classe en javascript

//class in es6 are just functional constructor.
class PersonES6{
  constructor(firstname,lastname,age){
    this.firstname= firstname;
    this.lastname=lastname;
    this.age=age
  }
  aboutPerson(){
  console.log(`My name is ${this.firstname} ${this.lastname} and I am ${this.age} years old`)
  }
}

const shirshakES6= new Person('Shirshak','Kandel',25)
shirshakES6.aboutPerson();
Sab Tech

classe en javascript


class Students {
    name;
    address;
    schoolName = "Morning Sun School";
    constructor(name,address,fatherName){
        this.name = name;
        this.address = address;
        this.fatherName = fatherName;
    }
    raceCompetition(){
        console.log(this.name, "start to run")
    }
}
const olivia = new Students("Olivia", "USA","James");
const emma = new Students("Emma", "UK", "alex");

console.log(olivia);
olivia.raceCompetition()

console.log(emma);
emma.raceCompetition()

// output of olivia
Students {
  name: 'Olivia',
  address: 'USA',
  schoolName: 'Morning Sun School',
  fatherName: 'James'
}
Olivia start to run

// output of Emma
Students {
  name: 'Emma',
  address: 'UK',
  schoolName: 'Morning Sun School',
  fatherName: 'alex'
}
Emma start to run
Ariful Islam Adil(Code Lover)

classe en javascript


class Students {
    name;
    address;
    schoolName = "Morning Sun School";
    constructor(name,address,fatherName){
        this.name = name;
        this.address = address;
        this.fatherName = fatherName;
    }
    raceCompetition(){
        console.log(this.name, "start to run")
    }
}
const olivia = new Students("Olivia", "USA","James");
const emma = new Students("Emma", "UK", "alex");

console.log(olivia);
olivia.raceCompetition()

console.log(emma);
emma.raceCompetition()

// output of olivia
Students {
  name: 'Olivia',
  address: 'USA',
  schoolName: 'Morning Sun School',
  fatherName: 'James'
}
Olivia start to run

// output of Emma
Students {
  name: 'Emma',
  address: 'UK',
  schoolName: 'Morning Sun School',
  fatherName: 'alex'
}
Emma start to run
Ariful Islam Adil(Code Lover)

classe en javascript


class Students {
    name;
    address;
    schoolName = "Morning Sun School";
    constructor(name,address,fatherName){
        this.name = name;
        this.address = address;
        this.fatherName = fatherName;
    }
    raceCompetition(){
        console.log(this.name, "start to run")
    }
}
const olivia = new Students("Olivia", "USA","James");
const emma = new Students("Emma", "UK", "alex");

console.log(olivia);
olivia.raceCompetition()

console.log(emma);
emma.raceCompetition()

// output of olivia
Students {
  name: 'Olivia',
  address: 'USA',
  schoolName: 'Morning Sun School',
  fatherName: 'James'
}
Olivia start to run

// output of Emma
Students {
  name: 'Emma',
  address: 'UK',
  schoolName: 'Morning Sun School',
  fatherName: 'alex'
}
Emma start to run
Ariful Islam Adil(Code Lover)

classe en javascript

class Students {
    name;
    address;
    schoolName = "Morning Sun School";
    constructor(name,address,fatherName){
        this.name = name;
        this.address = address;
        this.fatherName = fatherName;
    }
}
const olivia = new Students("Olivia", "USA","James");
const emma = new Students("Emma", "UK", "alex");
console.log(olivia);
console.log(emma);

// Output of Olivia
Students {
    name: 'Olivia',
    address: 'USA',
    schoolName: 'Morning Sun School',
    fatherName: 'James'
  }
// Output of Emma
  Students {
    name: 'Emma',
    address: 'UK',
    schoolName: 'Morning Sun School',
    fatherName: 'alex'
  }
Ariful Islam Adil(Code Lover)

Réponses similaires à “classe en javascript”

Questions similaires à “classe en javascript”

Plus de réponses similaires à “classe en javascript” dans JavaScript

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code