PROWAREtech

articles » current » javascript » ie11 » ie11-prototype-math-trunc

JavaScript: IE11 Math.trunc() Method/Function

Create the Math.trunc() function for Internet Explorer 11.

Still developing for IE11? Well, this prototype is used to truncate any number to an integer.


Math.trunc = Math.trunc || function (num) {
	return num < 0 ? Math.ceil(num) : Math.floor(num);
};

Using the above code snippet:


Math.trunc = Math.trunc || function (num) {
	return num < 0 ? Math.ceil(num) : Math.floor(num);
};
alert("2314.8=" + Math.trunc(2314.8));

This site uses cookies. Cookies are simple text files stored on the user's computer. They are used for adding features and security to this site. Read the privacy policy.
CLOSE