Math Object in JavaScript.!

JavaScript Math obyekti raqamlar ustida matematik vazifalarni bajarishga imkon beradi va boshqa obyektlardan farq qilgan holda matematik obyektda konstruktor yo’q shuningdek matematik obyekt statik.!

Har qanday matematik xususiyat sintaksisi Math.property ko’rinishida bo’ladi.!

JavaScript Matematik xususiyatlari sifatida foydalanish mumkin bo’lgan 8 ta matematik konstantalarni taqdim etadi:
Math.E // Eyler raqamini qaytaradi.!
Math.PI // PIni qaytaradi.!
Math.SQRT2 // 2 ning kvadrat ildizini qaytaradi.!
Math.SQRT1_2 // 1/2 kvadrat ildizini qaytaradi.!
Math.LN2 // 2 ning natural logarifmini qaytaradi.!
Math.LN10 // 10 ning natural logarifmini qaytaradi.!
Math.LOG2E // E ning 2 ta logarifmini qaytaradi.!
Math.LOG10E //E ning 10 ta logarifmini qaytaradi.!

1.

let mathem=Math.E;
console.log(mathem);
//natija - 2.718281828459045
Enter fullscreen mode Exit fullscreen mode

2.

let mathem=Math.PI;
console.log(mathem);
//natija - 3.141592653589793
Enter fullscreen mode Exit fullscreen mode

3.

let mathem=Math.SQRT2;
console.log(mathem);
//natija - 1.4142135623730951
Enter fullscreen mode Exit fullscreen mode

4.

let mathem=Math.SQRT1_2;
console.log(mathem);
//natija - 0.7071067811865476
Enter fullscreen mode Exit fullscreen mode

5.

let mathem=Math.LN2;
console.log(mathem);
//natija - 0.6931471805599453
Enter fullscreen mode Exit fullscreen mode

6.

let mathem=Math.LN10;
console.log(mathem);
//natija - 2.302585092994046
Enter fullscreen mode Exit fullscreen mode

7.

let mathem=Math.LOG2E;
console.log(mathem);
//natija - 1.4426950408889634
Enter fullscreen mode Exit fullscreen mode

8.

let mathem=Math.LOG10E;
console.log(mathem);
//natija 0.4342944819032518
Enter fullscreen mode Exit fullscreen mode

JavaScriptda sonlarni butun songa yaxlitlashning 4 ta umumiy usuli mavjud.!

1.Math.round(x) – kiritilgan raqamni haqqoniy yaxlitlaydi.!

let result1=Math.round(12.1);
console.log(result1);
//natija - 12 let result2=Math.round(12.5);
console.log(result2);
//natija - 13 let result3=Math.round(12.9);
console.log(result3);
//natija - 13
Enter fullscreen mode Exit fullscreen mode

2.Math.ciel(x)– kiritilgan raqamni katta tomonga yaxlitlaydi.!

let result1=Math.ceil(12.001);
console.log(result1);
//natija - 13 let result2=Math.ceil(12.5);
console.log(result2);
//natija - 13 let result3=Math.ceil(12.9);
console.log(result3);
//natija - 13
Enter fullscreen mode Exit fullscreen mode
  1. Math.floor(x) – kiritilgan raqamni kichik tomonga yaxlitlaydi.!
let result1=Math.floor(12.001);
console.log(result1);
//natija - 12 let result2=Math.floor(12.5);
console.log(result2);
//natija - 12 let result3=Math.floor(12.9);
console.log(result3);
//natija - 12
Enter fullscreen mode Exit fullscreen mode
  1. Math.trunc(x) – kiritilgan raqamni butun qismini qaytaradi.!
let result1=Math.trunc(0.9);
console.log(result1);
//natija - 0 let result2=Math.trunc(-12.5);
console.log(result2);
//natija - (-12) let result3=Math.trunc(12.9);
console.log(result3);
//natija - 12
Enter fullscreen mode Exit fullscreen mode

Math.sign(x)– Agar argument musbat bo’lsa 1 qaytaradi, argument manfiy bo’lsa -1 qaytaradi, argument nol bo’lsa nol qaytaradi manfiy nol bo’lsa manfiy nol qaytaradi.!

let result1=Math.sign(12.12);
console.log(result1);
//natija - 1 let result2=Math.sign(0);
console.log(result2);
//natija - 0 let result3=Math.sign(-9.4);
console.log(result3);
//natija - (-1)
Enter fullscreen mode Exit fullscreen mode

Math.pow(x,y) – x argumentni y argument marta darajaga ko’tarib natijani qaytaradi.!

let result1=Math.pow(3,4);
console.log(result1);
//natija - 81 let result2=Math.pow(25,2);
console.log(result2);
//natija - 625
Enter fullscreen mode Exit fullscreen mode

Math.sqrt(x)– Argumentni kvadrat ildizdan chiqarib natijani qaytaradi.!

let result1=Math.sqrt(25);
console.log(result1);
//natija - 5 let result2=Math.sqrt(1200);
console.log(result2);
//natija - 34.64101615137755
Enter fullscreen mode Exit fullscreen mode

Math.abs(x)– Argumentni moduldan chiqarib natijani qaytaradi.!

let result1=Math.abs(-2);
console.log(result1);
//natija - 2 let result2=Math.abs(2);
console.log(result2);
//natija - 2
Enter fullscreen mode Exit fullscreen mode

Math.min(), Math.max()– Ushbu metod jadvaldagi raqamlar ichidan eng kattasi va eng kichigini topishda yordam beradi.!


let result1=Math.max(12,13,14,24,26,-1,-12,77);
console.log(result1);
//natija - 77 let result2=Math.min(12,13,14,24,26,-1,-12,77);
console.log(result2);
//natija - (-12)
Enter fullscreen mode Exit fullscreen mode

Math.log(x) – x ning natural logarifmini qaytaradi.!

let result1=Math.log(1);
console.log(result1);
//natija - 0 let result2=Math.log(10);
console.log(result2);
//natija - 2.302585092994046
Enter fullscreen mode Exit fullscreen mode

Math.log2(x)-x ning 2 ta logarifmini qaytaradi.!

let result1=Math.log2(1);
console.log(result1);
//natija - 0 let result2=Math.log2(1024);
console.log(result2);
//natija - 10
Enter fullscreen mode Exit fullscreen mode

Math.log10(x)-x ning 10 ta logarifmini qaytaradi.!

let result1=Math.log10(10);
console.log(result1);
//natija - 1 let result2=Math.log10(10000);
console.log(result2);
//natija - 4
Enter fullscreen mode Exit fullscreen mode

Math.random()


Discover more from Coursity

Subscribe to get the latest posts sent to your email.

Leave a Comment

Your email address will not be published. Required fields are marked *

Discover more from Coursity

Subscribe now to keep reading and get access to the full archive.

Continue reading

Scroll to Top
Select dc location :. Cloud computing solid future. Trusted restaurant review & rating.