Showing posts with label custome method using javascript. Show all posts
Showing posts with label custome method using javascript. Show all posts

Saturday, August 23, 2025

Custom method using prototype in JavaScript.

<!DOCTYPE html>

<html>

<head>

  <title>Custom Prototype Method</title>

</head>

<body>

  <h2>Prototype Sum Method</h2>

  <button onclick="calculate()">Click to Calculate</button>


  <script>

    // ✅ Add custom method using prototype

    Number.prototype.add = function(num) {

      return this + num;

    };


    function calculate() {

      let result = (10).add(20); // using custom method

      alert("The sum is: " + result);

    }

  </script>

</body>

</html>


๐Ÿค– AI เค”เคฐ PC: เคฌเคฆเคฒเคคी เคฆुเคจिเคฏा เค•ी เคจเคˆ เคคाเค•เคค

 เค†เคœ Artificial Intelligence (AI) เค•ेเคตเคฒ เคเค• เคคเค•เคจीเค• เคจเคนीं, เคฌเคฒ्เค•ि เคถिเค•्เคทा, เคต्เคฏเคตเคธाเคฏ, เคธ्เคตाเคธ्เคฅ्เคฏ, เคธुเคฐเค•्เคทा เค”เคฐ เคถोเคง เค•े เค•्เคทेเคค्เคฐ เคฎें เค•्เคฐांเคคि เคฒा เคฐเคนी เคนै। AI เค”...