JavaScript prefers various data types to hold various kinds of values. The following are some data types in javascript.
- Undefined: Undefined value.
- Number: Numeric value.
- String: Sequence strings.
- Boolean: Boolean value (True or false).
- Array: Set of similar values.
- Object: Represent the Instance or properties of an object.
- Null: No values.
Note
- JavaScript has dynamic types. This means that the same variable can be used to hold various data types.
- JavaScript arrays are written with square brackets and separated by commas.
- JavaScript objects are written with curly braces and separated by commas.
Example: Data types in javascript.
<script > var n=""; //Null or empty value var a; //The value and type of u is undefined var b=21; //numbers var c=3.14; //numbers with decimal var d=1e6; //1000000 large numbers with scientific notation. var e=23e-4; //0.0023 small numbers with scientific notation. var f="DGT Teck" //String (b==c) //booleans return false (b==b) //booleans return true var webp=["Js","html","CSS","PHP"]; //Array var student={name:"minilik", age:17; sex:"male"};//Object </script>
0 Comments