This is a built-in numeric type. There are an enormous amount of methods we can use with the number. I am listing something mostly used and important number methods:
If we start from the very beginning and most used debug tool which is the console.
console.log(5/2); // which is equal to 2.5
which gives the value of 2, not 2.5. Therefore, if we want to get the upper closest or the lower closest value we’ll use Math.ceil and Math. floor respectfully. For example,
console.log(Math.floor(5/2)); // which is equal to 2
console.log(Math.ceil(5/2)); // which is equal to 3
This is used to manipulate a queue of characters. Useful for holding data that can be represented in text format.
console.log(‘raufu’.charAt(1)); // which give the output ‘a’ as it starts count from 0 and in 1th index position there is ‘a’
Apart from this .toUpperCase() and .toLowerCase() methods give output in all characters of string in upper case and lower case respectfully.
console.log(‘raufu’.toUpperCase()); // which gives the value ‘RAUFU’
console.log(‘RaUFu’.toLowerCase()); // which gives the value “raufu”
This is used to keep elements of any type-together.
const names = [‘Raufu’, ‘Prezens’]
console.log(names.length); // which gives the value 2 that is basically the total number of elements in the array.
console.log(names); // which gives the value Raufu as it is in the first position.
This is built and has methods for mathematical functions. It basically works with the Number type.
Math.abs(a); returns the value of a in absolute form
Math.random(); returns random value everytime it is called
I will try to update the article later and thank you for reading this article.