Skip to content

Commit 7362947

Browse files
feat: add math pi
1 parent 31d1ef3 commit 7362947

File tree

3 files changed

+77
-4
lines changed

3 files changed

+77
-4
lines changed

.vscode/settings.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
"Chavda",
66
"Eich",
77
"iambrijeshtoo",
8-
"Monaspace"
8+
"Monaspace",
9+
"Monokai",
10+
"Noctis",
11+
"Obscuro"
912
],
1013
"editor.tokenColorCustomizations": {
1114
"comments": "",

32_math_api/1_math_api.js

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// - In JavaScript there is Math object that gives PI values.
2+
// - This PI value is constant at the core level of JavaScript.
3+
// - Sometimes in interview they ask about how we can change the value of PI to whatever you want.
4+
5+
const descriptor = Object.getOwnPropertyDescriptor(Math, "PI");
6+
// console.log(descriptor);
7+
8+
// - Here you can see in the output that there are properties which we can't access it.
9+
// - This properties are hard coded inside the JavaScript. Because of that we are not able to change the value.
10+
11+
// Output:
12+
// {
13+
// value: 3.141592653589793,
14+
// writable: false,
15+
// enumerable: false,
16+
// configurable: false
17+
// }
18+
19+
// How can we setup custom access for the object's properties.
20+
21+
// Step: 1
22+
const object = {
23+
key1: "value1",
24+
key2: "value2",
25+
key3: "value3",
26+
27+
method: function () {
28+
console.log("I am method");
29+
},
30+
};
31+
32+
console.log(Object.getOwnPropertyDescriptor(object, "key"));
33+
34+
// Output:
35+
// {
36+
// value: 'value',
37+
// writable: true,
38+
// enumerable: true,
39+
// configurable: true
40+
// }
41+
42+
// Step: 2
43+
// - As you can see in the output we have properties that can help use to setup custom access for the object property -> `key`.
44+
45+
Object.defineProperty(object, "key1", {
46+
// writable: false,
47+
enumerable: false, // This will not iterate the `key1` property in for loop.
48+
});
49+
50+
// console.log(Object.getOwnPropertyDescriptor(object, "key"));
51+
52+
for (let [key, value] of Object.entries(object)) {
53+
if (typeof value !== "function") {
54+
console.log(`${key}:${value}`);
55+
}
56+
}

README.md

+17-3
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,22 @@
147147
1. setTimeout()
148148
2. setInterval()
149149

150-
151150
<!-- OOP -->
152-
1. Literal Object
151+
152+
1. Literal Object
153153
2. Constructor Function
154-
3.
154+
155+
# Monospace Font
156+
157+
1. MonoLisa
158+
2. Fira Mono
159+
3. Cascadia Code
160+
4. JetBrains Mono
161+
5. Commit Mono
162+
163+
# Theme - Pitch Dark Background
164+
165+
1. Ayu - Dark
166+
2. Night Owl
167+
3. Noctis - Obscuro
168+
4. Monokai Pro - Spectrum

0 commit comments

Comments
 (0)