About Data Types | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

About Data Types

Can you please say more about Data Types with examples . ?

16th Aug 2020, 7:42 AM
Nafew Ahmed
Nafew Ahmed - avatar
3 Answers
+ 1
In computer science and computer programming, a data type or simply type is an attribute of data that tells the compiler or interpreter how the programmer intends to use the data. Most programming languages support basic data types of integer numbers (of varying sizes), floating-point numbers (which approximate real numbers), characters, and Booleans. A data type constrains the values that expression, such as a variable or a function, might take. This data type defines the operations that can be done on the data, the meaning of the data, and the way values of that type can be stored. A data type provides a set of values from which an expression (i.e. variable, function, etc.) may take its values. There are six basic data types in JavaScript which can be divided into three main categories: primitive (or primary), composite (or reference), and special data types. String, Number, and Boolean are primitive data types. Object, Array, and Function (which are all types of objects) are composite data types. Whereas Undefined and Null are special data types. These are: 1. The String Data Type: var a = 'Hi there!'; 2. The Number Data Type: var c = 4.25e+6; 3. The Boolean Data Type: var isReading = true; 4. The Undefined Data Type: var a; var b = "Hello World!" alert(a) // Output: undefined alert(b) // Output: Hello World! 5. The Null Data Type: var a = null; alert(a); // Output: null 6. The Object Data Type: var emptyObject = {}; var person = {"name": "Clark", "surname": "Kent", "age": "36"}; // For better reading var car = { "modal": "BMW X3", "color": "white", "doors": 5 } 7. The Array Data Type: var colors = ["Red", "Yellow", "Green", "Orange"]; alert(colors[0]); 8. The Function Data Type: var greeting = function(){ return "Hello World!"; } alert(greeting()); 9. The typeof Operator: typeof 15; Thanks...
16th Aug 2020, 7:57 AM
Bits!
+ 1
Thank you so much
16th Aug 2020, 8:08 AM
Nafew Ahmed
Nafew Ahmed - avatar