we are going to start with its basic built in primitive data types. We have a few objectives here:
- Introduce the 5 primitive data types.
- Work with numbers and numeric operators.
- Work with strings and common string methods.
5 Primitive Data types
So one of the big ideas at the core of every programming language is the language ability to differentiate between different categories of data.
For instance, a language could differentiate between a number and a word or it could differentiate between whole number and fractional number or a positive number and or a negative number and it varies from language to language to language.
So the first one is number and we have three examples here.
A whole number that is ‘7’ for a fractional, a decimal number 10.5 and a negative number 20.
So again numbers are just a category for whole numbers fractional numbers and negative numbers.
You can do this with any site.
I am going to write so codes here.
If you write any number then it will get back to you exactly like you enter.
You can also do mathematical solutions and JS follows the mathematical rules.
So performing things like addition, Multiplication, division and subtraction are really easy and the way that those work write some similar expression and hit enter.
Here is an example of numbers below.
You can see in the output that we have performed different task like multiplication, division, subtraction and addition by straight typing the mathematical equation in a Chrome Developer Console.
Modulo Operator / Remainder Operator
Another chrome’s operator which is quiet unfamiliar to those who has no background knowledge of programming.
Remainder operator uses a percentage sign (%).
If we write 100 modulo (%) 3 = Then it will take 3 and divided it into 100 as many times as it goes in as a whole number.
So that would be 33 times and then it will take the remainder that is 1.
The next category that we have is called strings. They are basically a text. The important thing is that they are inside of quotes. Here we have two examples, so we have the word “Hellow Geeks” which is inside of quotes. This is one string even though it is consist of multiple words. Here is an example of string below:
Quotes can be of double and single type.
So just as an example If we type “Hello Geeks!” and hit enter, it just spits the value back as it is.
Same rule applies with the single quote: