JavaScript Core Concepts -Numeric and Mathematical Concepts
What is JavaScript?
JavaScript is a scripting language that enables you to create dynamically updating content, control multimedia, animate images, and pretty much everything else. _developer.mozilla.org
JavaScript is a Programming Language for Website Development. It is a text-based programming language used both on the client-side and server-side. It is the world’s one of the most popular programming language. It is very easy to learn.
Today we are going to see some basic Numeric and Mathematical concepts of JavaScript.
Let’s talk about;
About Number
Abs
Round
Ceil
Floor
Random
Parse Float
Parse Int
‘ ’
To Fixed
About Number
JavaScript has only one type of number. Numbers can be written with or without decimals.
Abs
abs method used to make negative number positive.
Round
Round keyword is used to convert a fraction number in a round/meaningful/integer figure.
If, the value is less then .5 ,it will remove the fraction. And, if the value is .5 or more then .5 it will make it 1 number bigger.
Ceil/Floor
Your fraction value may less then .5 or more then .5 ,but you want to make it 1 bigger, then use the keyword ‘ceil’.
Your fraction value may less then .5 or more then .5 ,but you want to make it 1 smaller, then use the keyword ‘floor’.
Ceil means the ceil of your room, which is highest. And, floor means the floor of your room, which is lowest.
Random
You can ask your computer to pick/show a random number using the keyword ‘random’. Then you can do anything with the random number.
Parse Float, Parse Int, ‘ ’
parseFloat: Convert string to number, var name = parseFloat(var name);
parseInt: Remove fraction from integers, var name = parseInt(var name);
‘ ’ : Convert number to string, var name = ‘ ’ + (var name);
Sqrt
The sqrt method used to do square root of a number.
To Fixed
The To Fixed method used to convert a number into a string, rounding the number to keep only the decimals you want. When you do mathematical operation with some float number, it will see you the whole answer. With it, you can see the answer in 5 numbers, 6 numbers and what in your want. Keep it mind it add/remove numbers from the float.