Skip to content

Commit 8b61775

Browse files
committed
Edit: Programs and Readme
1 parent 0e62d54 commit 8b61775

File tree

5 files changed

+467
-2
lines changed

5 files changed

+467
-2
lines changed

01.Basic/Declared_Types.ipynb

Lines changed: 267 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,267 @@
1+
{
2+
"cells": [
3+
{
4+
"attachments": {},
5+
"cell_type": "markdown",
6+
"metadata": {
7+
"dotnet_interactive": {
8+
"language": "csharp"
9+
},
10+
"polyglot_notebook": {
11+
"kernelName": "csharp"
12+
}
13+
},
14+
"source": [
15+
"# Delcared Types"
16+
]
17+
},
18+
{
19+
"attachments": {},
20+
"cell_type": "markdown",
21+
"metadata": {
22+
"dotnet_interactive": {
23+
"language": "csharp"
24+
},
25+
"polyglot_notebook": {
26+
"kernelName": "csharp"
27+
}
28+
},
29+
"source": [
30+
"### `var`, `let` and `const` difference in JavaScript \n",
31+
"\n",
32+
"Learn From `ChatGPT`\n",
33+
"\n",
34+
"In JavaScript, var, let, and const are all used to declare variables, but they have some differences in terms of their behavior and scope."
35+
]
36+
},
37+
{
38+
"attachments": {},
39+
"cell_type": "markdown",
40+
"metadata": {
41+
"dotnet_interactive": {
42+
"language": "csharp"
43+
},
44+
"polyglot_notebook": {
45+
"kernelName": "csharp"
46+
}
47+
},
48+
"source": [
49+
"`var`: In JavaScript, var was the original way to declare a variable. It is function-scoped, which means that a variable declared with var exists throughout the whole function in which it is defined, including any nested functions. If a variable is declared with var outside a function, it becomes a global variable and is available throughout the whole program. One important thing to note is that var allows for variable hoisting, which means that the variable can be accessed before it is declared.\n",
50+
"\n",
51+
"Example:"
52+
]
53+
},
54+
{
55+
"cell_type": "code",
56+
"execution_count": null,
57+
"metadata": {
58+
"dotnet_interactive": {
59+
"language": "javascript"
60+
},
61+
"polyglot_notebook": {
62+
"kernelName": "javascript"
63+
},
64+
"vscode": {
65+
"languageId": "polyglot-notebook"
66+
}
67+
},
68+
"outputs": [],
69+
"source": [
70+
"function exampleFunction() {\n",
71+
" var x = 1;\n",
72+
" if (true) {\n",
73+
" var x = 2; // This is the same variable as above - not a new one\n",
74+
" console.log(x); // outputs 2\n",
75+
" }\n",
76+
" console.log(x); // outputs 2\n",
77+
"}"
78+
]
79+
},
80+
{
81+
"attachments": {},
82+
"cell_type": "markdown",
83+
"metadata": {
84+
"dotnet_interactive": {
85+
"language": "javascript"
86+
},
87+
"polyglot_notebook": {
88+
"kernelName": "javascript"
89+
}
90+
},
91+
"source": [
92+
"`let`: let was introduced in ECMAScript 6 (ES6) as a new way to declare a variable. It is block-scoped, which means that a variable declared with let only exists within the block in which it is defined. Blocks include functions, loops, and statements that are surrounded by curly braces. Variables declared with let can be updated, but not redeclared.\n",
93+
"\n",
94+
"Example:"
95+
]
96+
},
97+
{
98+
"cell_type": "code",
99+
"execution_count": 1,
100+
"metadata": {
101+
"dotnet_interactive": {
102+
"language": "javascript"
103+
},
104+
"polyglot_notebook": {
105+
"kernelName": "javascript"
106+
},
107+
"vscode": {
108+
"languageId": "polyglot-notebook"
109+
}
110+
},
111+
"outputs": [],
112+
"source": [
113+
"function exampleFunction() {\n",
114+
" let x = 1;\n",
115+
" if (true) {\n",
116+
" let x = 2; // This is a new variable with the same name as above\n",
117+
" console.log(x); // outputs 2\n",
118+
" }\n",
119+
" console.log(x); // outputs 1\n",
120+
"}"
121+
]
122+
},
123+
{
124+
"attachments": {},
125+
"cell_type": "markdown",
126+
"metadata": {
127+
"dotnet_interactive": {
128+
"language": "javascript"
129+
},
130+
"polyglot_notebook": {
131+
"kernelName": "javascript"
132+
}
133+
},
134+
"source": [
135+
"`const`: const was also introduced in ES6 as a way to declare variables. It is also block-scoped and cannot be reassigned, but it does not mean that the value cannot be changed. If a variable is declared with const, it must be assigned a value at the time of declaration and cannot be reassigned later in the code.\n",
136+
"\n",
137+
"Example:"
138+
]
139+
},
140+
{
141+
"cell_type": "code",
142+
"execution_count": null,
143+
"metadata": {
144+
"dotnet_interactive": {
145+
"language": "javascript"
146+
},
147+
"polyglot_notebook": {
148+
"kernelName": "javascript"
149+
},
150+
"vscode": {
151+
"languageId": "polyglot-notebook"
152+
}
153+
},
154+
"outputs": [],
155+
"source": [
156+
"function exampleFunction() {\n",
157+
" const x = 1;\n",
158+
" if (true) {\n",
159+
" const x = 2; // This is a new variable with the same name as above\n",
160+
" console.log(x); // outputs 2\n",
161+
" }\n",
162+
" console.log(x); // outputs 1\n",
163+
"}"
164+
]
165+
},
166+
{
167+
"attachments": {},
168+
"cell_type": "markdown",
169+
"metadata": {
170+
"dotnet_interactive": {
171+
"language": "javascript"
172+
},
173+
"polyglot_notebook": {
174+
"kernelName": "javascript"
175+
}
176+
},
177+
"source": [
178+
"In `summary`, var is function-scoped, can be hoisted, and can be updated and redeclared. let and const are block-scoped, cannot be hoisted, and let can be updated but not redeclared, while const cannot be reassigned."
179+
]
180+
}
181+
],
182+
"metadata": {
183+
"kernelspec": {
184+
"display_name": ".NET (C#)",
185+
"language": "C#",
186+
"name": ".net-csharp"
187+
},
188+
"polyglot_notebook": {
189+
"kernelInfo": {
190+
"defaultKernelName": "csharp",
191+
"items": [
192+
{
193+
"aliases": [
194+
"c#",
195+
"C#"
196+
],
197+
"languageName": "C#",
198+
"name": "csharp"
199+
},
200+
{
201+
"aliases": [
202+
"frontend"
203+
],
204+
"languageName": null,
205+
"name": "vscode"
206+
},
207+
{
208+
"aliases": [
209+
"js"
210+
],
211+
"languageName": "JavaScript",
212+
"name": "javascript"
213+
},
214+
{
215+
"aliases": [],
216+
"languageName": "KQL",
217+
"name": "kql"
218+
},
219+
{
220+
"aliases": [],
221+
"name": ".NET"
222+
},
223+
{
224+
"aliases": [
225+
"f#",
226+
"F#"
227+
],
228+
"languageName": "F#",
229+
"name": "fsharp"
230+
},
231+
{
232+
"aliases": [],
233+
"languageName": "HTML",
234+
"name": "html"
235+
},
236+
{
237+
"aliases": [],
238+
"languageName": "Mermaid",
239+
"name": "mermaid"
240+
},
241+
{
242+
"aliases": [
243+
"powershell"
244+
],
245+
"languageName": "PowerShell",
246+
"name": "pwsh"
247+
},
248+
{
249+
"aliases": [],
250+
"languageName": "SQL",
251+
"name": "sql"
252+
},
253+
{
254+
"aliases": [],
255+
"name": "value"
256+
},
257+
{
258+
"aliases": [],
259+
"name": "webview"
260+
}
261+
]
262+
}
263+
}
264+
},
265+
"nbformat": 4,
266+
"nbformat_minor": 2
267+
}
File renamed without changes.

0 commit comments

Comments
 (0)