জাভাস্ক্রিপ্টে প্রোটোটাইপ মডিফাই করার জন্য নিচের কোডটি দেখুন।
উদাহরণ
<!DOCTYPE html> <html lang="bn"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>প্রোটোটাইপ মডিফিকেশন</title> <style> body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } .result { font-size: 20px; font-weight: 500; color: blueviolet; } </style> </head> <body> <h1>জাভাস্ক্রিপ্টে প্রোটোটাইপ মডিফাই করা</h1> <div class="result"></div> <button class="Btn">এখানে ক্লিক করুন</button> <h3>উপরোক্ত বাটনে ক্লিক করুন আসল এবং মডিফাইড প্রোটোটাইপ ফাংশন দেখতে</h3> <script> let resEle = document.querySelector(".result"); let BtnEle = document.querySelector(".Btn"); function Person(name, age, occupation) { this.name = name; this.age = age; this.occupation = occupation; } Person.prototype.displayInfo = function () { return `নাম: ${this.name} বয়স: ${this.age} পেশা: ${this.occupation}<br>`; }; let person1 = new Person("Shawn", 20, "student"); let person2 = new Person("Rohan", 25, "Manager"); BtnEle.addEventListener("click", () => { resEle.innerHTML = "প্রোটোটাইপ মডিফাই করার আগে <br>" + person1.displayInfo() + person2.displayInfo(); Person.prototype.displayInfo = function () { return `পেশা: ${this.occupation} বয়স: ${this.age} নাম: ${this.name} <br> `; }; resEle.innerHTML +="<br>প্রোটোটাইপ মডিফাই করার পর <br>" + person1.displayInfo() + person2.displayInfo(); }); </script> </body> </html>
আউটপুট
প্রাথমিক অবস্থা:

'এখানে ক্লিক করুন' বাটনে ক্লিক করার পর:
