Skip to content

Commit 56d78aa

Browse files
fix: datatypes.js file
1 parent 6e8d8a3 commit 56d78aa

File tree

1 file changed

+38
-17
lines changed

1 file changed

+38
-17
lines changed

part1 (Basics)/02_datatypes.js

Lines changed: 38 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,50 @@
1-
// In javascript we do not need to specify type of the varialbe because if is dynamically used by javascript engine. We can use var data type. It can hold any type of data like String, Number, Boolen etc.
1+
// datatypes.js
22

3-
console.log("hello");
4-
// console.log("cai");
53
/*
4+
JavaScript is dynamically typed, so variables can hold any type of data without explicit type declaration.
65
7-
String
8-
Number
9-
Boolean
10-
Bigint
11-
Undefined
12-
null
13-
Object
14-
Symbol
6+
Common data types in JavaScript:
157
8+
1. String - Text wrapped in quotes
9+
2. Number - Numeric values (integers and floats)
10+
3. Boolean - true or false
11+
4. BigInt - For very large integers
12+
5. Undefined - A variable declared but not assigned a value
13+
6. Null - Represents intentional absence of any object value
14+
7. Object - Collections of key-value pairs, arrays, functions, etc.
15+
8. Symbol - Unique and immutable primitive values
1616
*/
1717

18-
// var score = 102;
18+
// Examples of different data types:
1919

20-
let score = 102;
20+
// String
2121
let name = "whoami";
22-
let isLoggedin = false;
22+
console.log(name); // whoami
23+
24+
// Number
25+
let score = 102;
26+
console.log(score); // 102
27+
28+
// Boolean
29+
let isLoggedIn = false;
30+
console.log(isLoggedIn); // false
2331

24-
// object
32+
// Object - Array
2533
let teaTypes = ["lemon tea", "orange tea", "oolong tea"];
26-
let user = { firstname: "whoami", lastname: "dsnake0" }
34+
console.log(teaTypes); // ["lemon tea", "orange tea", "oolong tea"]
2735

36+
// Object - Plain Object
37+
let user = { firstName: "whoami", lastName: "dsnake0" };
38+
console.log(user); // { firstName: "whoami", lastName: "dsnake0" }
39+
40+
// Assigning variable values
2841
let getScore = score;
29-
console.log(getScore)
42+
console.log(getScore); // 102
43+
44+
// Undefined example
45+
let something;
46+
console.log(something); // undefined
47+
48+
// Null example
49+
let emptyValue = null;
50+
console.log(emptyValue); // null

0 commit comments

Comments
 (0)