0% found this document useful (0 votes)
5 views1 page

HTML 4

The document contains JavaScript code demonstrating the creation of a sum function using both traditional and arrow function syntax, along with an immediately invoked function expression. It also defines an Employee class with a constructor and a method to display employee information, showcasing two employee instances. The code outputs the details of the employees to the console.

Uploaded by

ha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views1 page

HTML 4

The document contains JavaScript code demonstrating the creation of a sum function using both traditional and arrow function syntax, along with an immediately invoked function expression. It also defines an Employee class with a constructor and a method to display employee information, showcasing two employee instances. The code outputs the details of the employees to the console.

Uploaded by

ha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

1.

- function sum(a, b, c) {
return a + b + c;
}
- const sumArrow = (a, b, c) => a + b + c;

- const total = ((a, b, c) => a + b + c)(1, 2, 3);


console.log(total);

2.class Employee {
constructor(firstName, lastName, age, phone, address) {
this.firstName = firstName;
this.lastName = lastName;
this.age = age;
this.phone = phone;
this.address = address;
}

displayInfo() {
console.log(`Họ và tên: ${this.firstName} ${this.lastName}`);
console.log(`Tuổi: ${this.age}`);
console.log(`Số điện thoại: ${this.phone}`);
console.log(`Địa chỉ: ${this.address}`);
}
}

const employee1 = new Employee('Nguyễn', 'Văn A', 30, '0123456789', 'Hà Nội');
const employee2 = new Employee('Trần', 'Thị B', 25, '0987654321', 'TP.HCM');

employee1.displayInfo();
employee2.displayInfo()

You might also like