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

জাভাস্ক্রিপ্ট অবজেক্ট মেথড


জাভাস্ক্রিপ্ট অবজেক্ট মেথড হলো অবজেক্টের ওপর করা যেতে পারে এমন অ্যাকশন।

উদাহরণ

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Document</title> <style>    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .sample {       font-size: 18px;       font-weight: 500;       color: red;    } </style> </head> <body> <h1>JavaScript Object Methods</h1> Enter your Name <input type="text" class="name" /> Enter your Age <input class="age" type="number" /> <div class="sample"></div> <button class="Btn">CLICK HERE</button> <h3> Click on the above button to see if you are a legal adult or not </h3> <script>    let sampleEle = document.querySelector(".sample");    let nameEle = document.querySelector(".name");    let AgeEle = document.querySelector(".age");    document.querySelector(".Btn").addEventListener("click", () => {       let testObj = {name: nameEle.value, age: AgeEle.value,checkAdult() {             if (this.age >= 18) {                sampleEle.innerHTML = this.name + " you are a legal adult ";          } else             sampleEle.innerHTML = this.name + "you are not a legal adult ";          },       };       testObj.checkAdult();    }); </script> </body> </html>

আউটপুট

জাভাস্ক্রিপ্ট অবজেক্ট মেথড

নাম ও বয়স দিয়ে 'CLICK HERE' বাটনে ক্লিক করলে -

জাভাস্ক্রিপ্ট অবজেক্ট মেথড


  1. জাভাস্ক্রিপ্টে Blob অবজেক্ট

  2. জাভাস্ক্রিপ্টে মেথড শেয়ার করা

  3. জাভাস্ক্রিপ্টে RegExp অবজেক্ট

  4. জাভাস্ক্রিপ্টে অবজেক্ট ইলিশিয়ালাইজার