Skip to content

Commit 96e8f62

Browse files
committed
Update 03_typeof.js and Add 09_Date_And_Time.js.
1 parent e844471 commit 96e8f62

3 files changed

Lines changed: 100 additions & 2 deletions

File tree

03_typeof.js

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,75 @@
88

99

1010
console.log(typeof "Hello"); // "string"
11+
console.log(typeof String); // "function"
12+
console.log(typeof String()); // "string"
13+
console.log(typeof String("Hello")); // "string"
14+
1115
console.log(typeof 123); // "number"
16+
console.log(typeof Number); // "function"
17+
console.log(typeof Number()); // "number"
18+
console.log(typeof Number(123)); // "number"
19+
1220
console.log(typeof true); // "boolean"
21+
console.log(typeof Boolean); // "function"
22+
console.log(typeof Boolean()); // "boolean"
23+
console.log(typeof Boolean(true)); // "boolean"
24+
1325
console.log(typeof null); // "object" (historical bug in JavaScript)
26+
1427
console.log(typeof undefined); // "undefined"
28+
29+
console.log(typeof Symbol); // "function"
1530
console.log(typeof Symbol()); // "symbol"
31+
console.log(typeof Symbol("id")); // "symbol"
32+
console.log(typeof Symbol(123)); // "symbol"
33+
34+
console.log(typeof BigInt); // "function"
35+
console.log(typeof BigInt()); // TypeError - Cannot convert undefined to BigInt
36+
console.log(typeof BigInt("123")); // "bigint"
1637
console.log(typeof BigInt(123)); // "bigint"
38+
1739
console.log(typeof { name: "Hitarth", age: 24, single: true }); // "object"
40+
console.log(typeof Object); // "function"
41+
console.log(typeof Object()); // "object"
42+
console.log(typeof Object({ name: "Hitarth", age: 24, single: true })); // "object"
43+
1844
console.log(typeof [1, 2, 3]); // "object"
45+
console.log(typeof Array); // "function"
46+
console.log(typeof Array()); // "object"
47+
console.log(typeof Array(1, 2, 3)); // "object"
48+
1949
console.log(typeof function () { }); // "function" (special case - bacause they are callable objects)
50+
console.log(typeof Function); // "function"
51+
console.log(typeof Function()); // "function"
52+
console.log(typeof Function(() => { })); // "function"
53+
54+
console.log(typeof Date); // "function"
55+
console.log(typeof Date()); // "string"
56+
console.log(typeof new Date()); // "object"
57+
58+
console.log(typeof RegExp); // "function"
59+
console.log(typeof RegExp()); // "object"
60+
61+
console.log(typeof Map); // "function"
62+
console.log(typeof Map()); // TypeError - Constructor Map requires 'new'
63+
console.log(typeof new Map()); // "object"
64+
65+
console.log(typeof Set); // "function"
66+
console.log(typeof Set()); // TypeError - Constructor Set requires 'new'
67+
console.log(typeof new Set()); // "object"
68+
69+
console.log(typeof Error); // "function"
70+
console.log(typeof Error()); // "object"
71+
72+
console.log(typeof Math); // "object"
73+
74+
console.log(typeof JSON); // "object"
75+
76+
console.log(typeof Promise); // "function"
77+
console.log(typeof Promise()); // TypeError - Constructor Promise cannot be invoked without 'new'
78+
console.log(typeof new Promise()); // TypeError - Promise Resolver undefined is not a Function
79+
console.log(typeof new Promise(() => { })); // "object"
2080

2181

2282

08_Math.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ console.log(Math); // Object [Math] {}
66

77

88

9-
// Math Properties :-
9+
// MATH PROPERTIES :-
1010

1111
// .PI - return the value of PI
1212
console.log(Math.PI); // "3.141592653589793"
@@ -17,7 +17,7 @@ console.log(Math.PI); // "3.141592653589793"
1717

1818

1919

20-
// Math Methods :-
20+
// MATH METHODS :-
2121

2222
// .abs() - return the absolute (positive) value
2323
console.log(Math.abs(3)); // "3"

09_Date_And_Time.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// THE STANDARD DATE : January 1, 1970, UTC
2+
3+
4+
5+
// ------------------------------------------------------------------------------------------------
6+
7+
8+
9+
console.log(Date()); // "Wed Jul 01 2026 19:16:37 GMT+0530 (India Standard Time)" (current date and time in local format)
10+
let current_date = new Date();
11+
console.log(current_date); // "2026-07-01T13:47:08.154Z" (current date and time in UTC format)
12+
let current_time = Date.now();
13+
console.log(current_time); // "1782913964468" (current timestamp in milliseconds since January 1, 1970, UTC)
14+
15+
16+
17+
// ------------------------------------------------------------------------------------------------
18+
19+
20+
21+
// DATE METHODS :-
22+
23+
console.log(current_date.getDate()); // "1" (returns the day of the month (from 1-31))
24+
console.log(current_date.getDay()); // "3" (returns the day of the week (from 0-6) - 0: Sunday, 1: Monday, 2: Tuesday, 3: Wednesday, 4: Thursday, 5: Friday, 6: Saturday)
25+
console.log(current_date.getMonth()); // "6" (returns the month (from 0-11) - 0: January, 1: February, 2: March, 3: April, 4: May, 5: June, 6: July, 7: August, 8: September, 9: October, 10: November, 11: December)
26+
console.log(current_date.getFullYear()); // "2026" (returns the year (four digits))
27+
28+
console.log(current_date.getTime()); // "1782913964468" (returns the number of milliseconds since January 1, 1970, UTC)
29+
console.log(current_date.getMilliseconds()); // "763" (returns the milliseconds (from 0-999))
30+
console.log(current_date.getSeconds()); // "30" (returns the seconds (from 0-59))
31+
console.log(current_date.getMinutes()); // "23" (returns the minutes (from 0-59))
32+
console.log(current_date.getHours()); // "19" (returns the hours (from 0-23))
33+
34+
console.log(current_date.toDateString()); // "Wed Jul 01 2026" (returns the date in a human-readable format)
35+
console.log(current_date.toTimeString()); // "19:26:29 GMT+0530 (India Standard Time)" (returns the time in a human-readable format)
36+
console.log(current_date.toLocaleString()); // "7/1/2026, 7:28:09 PM" (returns the date and time in a human-readable format based on the locale)
37+
console.log(current_date.toLocaleDateString()); // "7/1/2026" (returns the date in a human-readable format based on the locale)
38+
console.log(current_date.toLocaleTimeString()); // "7:27:05 PM" (returns the time in a human-readable format based on the locale)

0 commit comments

Comments
 (0)