Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Вивчайте Declaring a Class | ES6 Class Fundamentals
JavaScript Classes and OOP Foundations

bookDeclaring a Class

To declare a class in JavaScript, you use the class keyword followed by the class name and a pair of curly braces to define its body. This structure forms the basis for creating objects with shared properties and behaviors. The class name should be written in PascalCase, meaning each word starts with a capital letter, such as Person or Car. At its simplest, a class can be empty, containing no properties or methods, but it still creates a new type that you can instantiate using the new keyword.

123456
// Declaring a simple class with no constructor or methods class Animal {} // Creating an instance of the Animal class const dog = new Animal(); console.log(dog); // Output: Animal {}
copy
question mark

Which of the following is the correct way to declare a class named 'Person' in JavaScript?

Select the correct answer

Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 1. Розділ 3

Запитати АІ

expand

Запитати АІ

ChatGPT

Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат

Awesome!

Completion rate improved to 6.25

bookDeclaring a Class

Свайпніть щоб показати меню

To declare a class in JavaScript, you use the class keyword followed by the class name and a pair of curly braces to define its body. This structure forms the basis for creating objects with shared properties and behaviors. The class name should be written in PascalCase, meaning each word starts with a capital letter, such as Person or Car. At its simplest, a class can be empty, containing no properties or methods, but it still creates a new type that you can instantiate using the new keyword.

123456
// Declaring a simple class with no constructor or methods class Animal {} // Creating an instance of the Animal class const dog = new Animal(); console.log(dog); // Output: Animal {}
copy
question mark

Which of the following is the correct way to declare a class named 'Person' in JavaScript?

Select the correct answer

Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 1. Розділ 3
some-alt