কম্পিউটার টিউটোরিয়াল

জাভাস্ক্রিপ্টে ডিকশনারি ক্লাস


এখানে MyMap ক্লাসের পূর্ণ বাস্তবায়ন দেওয়া হলো:

উদাহরণ

class MyMap {
    constructor() {
        this.container = {};
    }
    display() {
        console.log(this.container);
    }
    hasKey(key) {
        return key in this.container;
    }
    put(key, value) {
        this.container[key] = value;
    }
    delete(key) {
        if (this.hasKey(key)) {
            delete this.container[key];
            return true;
        }
        return false;
    }
    get(key) {
        return this.hasKey(key) ? this.container[key] : undefined;
    }
    keys() {
        return Object.keys(this.container);
    }
    values() {
        let values = [];
        for (let key in this.container) {
            values.push(this.container[key]);
        }
        return values;
    }
    clear() {
        this.container = {};
    }
    forEach(callback) {
        for (let prop in this.container) {
            // কলব্যাক কল করুন: callback(key, value)
            callback(prop, this.container[prop]);
        }
    }
}

  1. জাভাস্ক্রিপ্টে lastIndex প্রপার্টি

  2. জাভাস্ক্রিপ্টে continue স্টেটমেন্ট

  3. জাভাস্ক্রিপ্টে new.target

  4. C#-এ Object ক্লাস: বেস ক্লাস এবং এর মেথডসমূহ