© Khmer Angkor Academy - sophearithput168

Math Object

សេចក្តីផ្តើម

Math object គឺជា built-in object ក្នុង JavaScript ដែលផ្តល់នូវវិធីសាស្រ្ត និង properties សម្រាប់គណិតវិទ្យា។ វាមិនត្រូវការ constructor ទេ។

Math Properties

PropertyValueDescription
Math.PI3.14159...ចំនួន Pi
Math.E2.718...Euler's number
Math.LN20.693...Natural log of 2
Math.LN102.302...Natural log of 10
Math.SQRT21.414...Square root of 2

Math Methods - Rounding

Math.round(4.7);  // 5
Math.ceil(4.1);   // 5
Math.floor(4.9);  // 4
Math.trunc(4.9);  // 4

Methods សម្រាប់បង្គត់ចំនួន


Math Methods - Min/Max

Math.min(5, 10, 2, 8);  // 2
Math.max(5, 10, 2, 8);  // 10

រកតម្លៃតូចបំផុត និង ធំបំផុត


Math Methods - Power & Root

Math.pow(2, 3);   // 8
Math.sqrt(16);    // 4
Math.cbrt(27);    // 3

ស្វ័យគុណ និង ឫស


Math Methods - Random

Math.random();  // 0 to 1
Math.floor(Math.random() * 10);  // 0 to 9
Math.floor(Math.random() * 100) + 1;  // 1 to 100

បង្កើតលេខចៃដន្យ


Math Methods - Trigonometry

Math.sin(Math.PI / 2);  // 1
Math.cos(0);            // 1
Math.tan(Math.PI / 4);  // 1

ត្រីកោណមាត្រ (radian)


Math Methods - Absolute & Sign

Math.abs(-5);   // 5
Math.sign(-5);  // -1
Math.sign(5);   // 1
Math.sign(0);   // 0

តម្លៃពិតប្រាកដ និង សញ្ញា


Best Practices

  • ប្រើ Math.random() សម្រាប់លេខចៃដន្យ
  • ប្រើ Math.floor(), Math.ceil(), Math.round() ដើម្បីបង្គត់
  • ប្រើ Math.pow()** operator សម្រាប់ស្វ័យគុណ
  • ចងចាំ trigonometry methods ប្រើ radian
  • Math មិនអាច instantiate បានទេ

Interactive Examples

  • Rounding Calculator
  • Random Number Generator
  • Power & Root Calculator
  • Circle Calculator (using Math.PI)
  • Min/Max Finder
  • Trigonometry Visualizer

សង្ខេប

  • Math object ផ្តល់នូវវិធីសាស្រ្តគណិតវិទ្យា
  • Properties: PI, E, LN2, LN10, SQRT2
  • Methods: round, ceil, floor, min, max, pow, sqrt, random, etc.
  • មិនត្រូវការ constructor ទេ