Here I will give an example: let a = 16 let b = 9 console.log(a + b) console.log(a - b) console.log(a * b) console.log(a / b) console.log(a % b) /* 25 7 144 1.7777777777777777 7 */ The following is a mathematical operator on the number data type: The number data type can also perform arithmetic such as addition, subtraction, multiplication, division, etc. When we get the decimal data type, we add a period to the fraction of the number. The data type in number has integers and decimals. We have two variables that have integers and decimals. I give an example below: let x = 10 let y = 10.5 console.log(typeof(x)) console.log(typeof(y)) /* output: number number */ The number data type is a data type that has a number value. Examples are as follows: let someLaterData = null console.log(someLaterData) /* output: null */ Number Null will be replaced with another value but undefined will be replaced with the correct process. Null will be obtained under normal conditions and undefined from processing errors then the output will be generated. Null is usually used for temporary values in variables. Null is similar to undefined, except that null needs to be initialized to the variable. Typeof() is used to confirm the data type in a variable by returning the data type in the form of text. #Javascript basic data types codeIn the code example above we declared the variable x, but we were given any value. I give an example below: let x console.log(typeof(x)) /* output: undefined */ When we declare without initializing the value, the variable will get undefined. This data type will be known when we get a variable that has no value. Here are some data types that we will discuss this time: Its function is to distinguish the type of value according to its type.īefore you continue with this tutorial, you should study the previous tutorials:īasic JavaScript Part 1: What is JavaScript?īasic JavaScript Part 2: First Code and Comments Data type is a grouping of data based on its type. When we have a variable, it must have a data type. Previously we discussed variables for storing a value. Hello, how are you all friends, I hope you are always healthy and successful.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |