Tech TutorBangla Web Documentation
Portfolio
HomeHTMLCSSTailwind CSSJavaScriptTypeScriptReactNext.jsNode.jsExpressSocket.IOExpoWordPressPostgreSQLPrismaPostgresNestJSMongoDBDockerTanStackTanStack TableRTK QueryGitGitHub
  • JavaScript Documentation48টি অধ্যায়
প্রযুক্তি নির্বাচন
HomeHTMLCSSTailwind CSSJavaScriptTypeScriptReactNext.jsNode.jsExpressSocket.IOExpoWordPressPostgreSQLPrismaPostgresNestJSMongoDBDockerTanStackTanStack TableRTK QueryGitGitHub
  • Introduction
  • JavaScript কী?
  • Syntax & Comments
  • Variables
  • Data Types: Basics
  • Data Types: Conversion
  • Data Types: Advanced
  • Strings
  • Numbers & Math
  • Date & Time
  • Operators
  • Conditions
  • Loops
  • Functions: Basics
  • Functions: Intermediate
  • Functions: Advanced
  • Scope & Hoisting
  • Closures & this
  • ES6+ Modern
  • Arrays: Basics
  • Arrays: Intermediate
  • Arrays: Advanced
  • Objects: Basics
  • Objects: Intermediate
  • Objects: Advanced
  • Class: Basics
  • Class: Intermediate
  • Class: Advanced
  • DOM: Basics
  • DOM: Intermediate
  • DOM: Advanced
  • Events: Basics
  • Events: Intermediate
  • Events: Advanced
  • Async JavaScript
  • Promise
  • Async / Await
  • Fetch API
  • JSON
  • Modules
  • Browser Storage
  • Event Loop Deep
  • Prototype Chain
  • Iterators & Generators
  • WeakMap, WeakSet, Proxy
  • Error Handling
  • Practice Problems
  • Mini Projects
  • Basics
  • Functions & Scope
  • Types & Syntax
  • Arrays & Objects
  • Advanced
  • Functional Programming
  • Objects & Symbols
  • Async Deep Dive
  • Modern JavaScript
  1. Docs
  2. JavaScript
  3. JavaScript Class: Intermediate (ক্লাস)
JavaScriptIntermediate

JavaScript Class: Intermediate (ক্লাস)

extends, super, override, method overloading ধারণা, static, private field (#), getter/setter, instanceof — বাংলায়।

22টি অংশবাংলা ভাষায়

এবার class-কে দিয়ে inheritance, static, encapsulation — OOP-এর মাঝামাঝি ধাপের বিষয়গুলো।

extends — উত্তরাধিকার (Inheritance)

class Animal {
  constructor(name) {
    this.name = name;
  }

  speak() {
    return `${this.name} শব্দ করছে`;
  }
}

class Dog extends Animal {
  fetch() {
    return `${this.name} বল আনছে`;
  }
}

const dog = new Dog("টমি");
console.log(dog.speak()); // টমি শব্দ করছে (parent class থেকে)
console.log(dog.fetch()); // টমি বল আনছে (নিজের মেথড)

extends দিয়ে child class parent-এর সব property ও method পায় — নিজেও নতুন মেথড যোগ করতে পারে। এটাই code reuse-এর প্রধান কৌশল।

super — parent-কে ডাকা

class Vehicle {
  constructor(brand) {
    this.brand = brand;
  }
}

class Car extends Vehicle {
  constructor(brand, model) {
    super(brand); // parent-এর constructor চালায়
    this.model = model;
  }
}

const car = new Car("Toyota", "Corolla");
console.log(car.brand); // Toyota
console.log(car.model); // Corolla

super(...) constructor/মেথড-এ parent-কে ডাকতে হয় — constructor-এ `this` ব্যবহারের আগেই super() দিতে হবে, নাহলে error।

Method override

class Animal {
  speak() {
    return "কিছু শব্দ";
  }
}

class Dog extends Animal {
  speak() {
    return super.speak() + " — ঘেউ ঘেউ";
  }
}

const dog = new Dog();
console.log(dog.speak()); // কিছু শব্দ — ঘেউ ঘেউ

child class-এ একই নামের method লিখলে সেটি parent-এর version override করে — চাইলে super.speak() দিয়ে parent-এর version-ও ব্যবহার করা যায়।

Static property/method

class MathHelper {
  static pi = 3.1416;

  static square(n) {
    return n * n;
  }
}

console.log(MathHelper.pi);       // 3.1416
console.log(MathHelper.square(5)); // 25

// instance নয় — সরাসরি class-এ কল হয়
const helper = new MathHelper();
console.log(helper.square); // undefined

static-এর property/method instance-ভিত্তিক নয় — class-এর সাথেই থাকে। ইউটিলিটি helper-র জন্য উপযুক্ত।

Private field (#)

class BankAccount {
  #balance; // private — বাইরে থেকে দেখা যাবে না

  constructor(initial) {
    this.#balance = initial;
  }

  deposit(amount) {
    this.#balance += amount;
  }

  getBalance() {
    return this.#balance;
  }
}

const acc = new BankAccount(1000);
acc.deposit(500);
console.log(acc.getBalance()); // 1500
// console.log(acc.#balance); // SyntaxError — private!

# দিয়ে private — property/মেথড শুধু class-এর ভেতরেই অ্যাক্সেসযোগ্য। বাইরের code সরাসরি বদলাতে পারবে না — এটাই encapsulation।

Getter ও Setter

class User {
  constructor(first, last) {
    this.first = first;
    this.last = last;
  }

  get fullName() {
    return `${this.first} ${this.last}`;
  }

  set fullName(value) {
    [this.first, this.last] = value.split(" ");
  }
}

const user = new User("আনামুল", "হাসান");
console.log(user.fullName); // "আনামুল হাসান" (property-র মতো)
user.fullName = "প্রিয়াঞ্জলী দাস";
console.log(user.first); // প্রিয়াঞ্জলী

instanceof

class Animal {}
class Dog extends Animal {}

const dog = new Dog();

console.log(dog instanceof Dog);    // true
console.log(dog instanceof Animal); // true (parent-ও)
console.log(dog instanceof Object); // true
কৌশলকাজ
extendschild-কে parent-এর property/method দেয়
superparent-এর constructor/method ডাকায়
overridechild-এ একই নামের method পুনরায় লেখা
staticclass-এর সাথে থাকা (instance ছাড়া)
#privateencapsulation — class-এর ভেতরেই সীমাবদ্ধ
get/setproperty-র মতো access-use করা method
instanceofclass-এর instance যাচাই
super() আগে, this পরে

subclass-এর constructor-এ this ব্যবহারের আগে অবশ্যই super() ডাকা লাগবে — নাহলে ReferenceError।

শেষ প্যারায় নিজে practice করুন — কোড কপি করে নিজের এডিটরে চালিয়ে দেখুন।
আগেরJavaScript Class: Basics (ক্লাস)পরেরJavaScript Class: Advanced (ক্লাস)
এই পেজে
Tech Tutor

বাংলায় ওয়েব ডেভেলপমেন্ট ডকুমেন্টেশন শিখুন — ধাপে ধাপে।

Homeসব ডকুমেন্টেশনQuick Startআমার নোটস

© 2026 Tech Tutor. বাংলায় শিখুন, বাংলায় গড়ুন।

mdanamolhasan1998@gmail.com