জাভাস্ক্রিপ্ট ম্যাথ অবজেক্ট আমাদেরকে সংখ্যার উপর গাণিতিক অপারেশন করতে দেয়। এটিতে গাণিতিক ধ্রুবক এবং ফাংশনের বৈশিষ্ট্য এবং পদ্ধতি রয়েছে৷
জাভাস্ক্রিপ্ট ম্যাথ অবজেক্টকে এর কিছু বৈশিষ্ট্য এবং পদ্ধতি সহ প্রয়োগ করার কোডটি নিচে দেওয়া হল -
উদাহরণ
<!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 Math Object</h1>
<div class="sample"></div>
<div style="font-weight: bold; color: black;" class="result"></div>
<button class="Btn">CLICK HERE</button>
<h3>
Click on the above button to see some math Object methods
</h3>
<script>
let sampleEle = document.querySelector(".sample");
document.querySelector(".Btn").addEventListener("click", () => {
sampleEle.innerHTML = 'Math.round(7.7) = ' + Math.round(7.7) + '<br>';
sampleEle.innerHTML += 'Math.sqrt(121) = ' + Math.sqrt(121) + '<br>';
sampleEle.innerHTML += 'Math.pow(4,4) = ' + Math.pow(4,5) + '<br>';
});
</script>
</body>
</html> আউটপুট

"এখানে ক্লিক করুন" বোতামে ক্লিক করলে -
