js
Math.floor(number)الفرق عن trunc بيظهر مع السالب: Math.floor(-4.7) بتدّي -5، وMath.trunc(-4.7) بتدّي -4. مع الموجب الاتنين نفس الناتج.
البرهان
js
console.log(Math.floor(4.7), Math.floor(4.2));
console.log(Math.floor(-4.7));
console.log(Math.trunc(-4.7));
console.log(Math.floor(3));النتيجة
4 4 -5 -4 3