-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathData-Types.js
69 lines (49 loc) · 1.91 KB
/
Data-Types.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
//* Data Types - JavaScript
/* JavaScript is a dynamically typed programming language, which means that variables are not
They are bound to a specific data type and can change type during program execution.
Here are some of the fundamental data types in JavaScript: */
//? 1. **Number:**
// - Represents numeric values, either integer or floating point.
let integer = 5;
let decimal = 3.14;
//? 2. **String (Text String):**
// - Represents text and is defined between single or double quotes.
let name = "John";
let greeting = 'Hello, World!';
//? 3. **Boolean:**
// - Represents a logical value: `true` or `false`.
let isMajor = true;
let isMinor = false;
//? 4. **Undefined:**
// - Represents a variable that has been declared but has not been assigned a value.
let variableNotDefined;
//? 5. **Null:**
// - Represents the absence of a value or a null value.
let nullValue = null;
//? 6. **Object:**
/* - Represents a collection of properties. It can be created with curly braces `{}` or by the operator
`newObject()`.
*/
let person = {
name: "Anna",
age: 30,
single: true
};
//? 7. **Array:**
// - Represents an ordered collection of values, which can be of any type.
let numbers = [1, 2, 3, 4, 5];
let colors = ["red", "green", "blue"];
//? 8. **Function:**
// - Represents a function.
function add(a, b) {
return a + b;
}
//? 9. **Symbol:**
/*
- Represents a unique and immutable identifier, used to create object properties that are not
conventionally accessible.
*/
let symbol = Symbol("description");
/* These are the main data types in JavaScript. In addition, JavaScript has other types and
more specialized objects, and its flexibility in terms of dynamic typing allows it to adapt to a
variety of situations. */