Skip to content

Commit 376a1cd

Browse files
authored
Update 02-basic-knowledge-solution.md
1 parent 10af2ed commit 376a1cd

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

Exercises-And-Solutions/solutions/02-basic-knowledge-solution.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ document.write(
115115
);
116116
```
117117

118-
### Question 3. Check output of following in console
118+
### Question 3. Check output of following in console and validate the same.
119119

120120
```
121121
console.log(1 + 1);
@@ -124,7 +124,7 @@ console.log(200 + "300");
124124
console.log("learnjavascript" + 400);
125125
```
126126

127-
### Question 4. Check output of following in console
127+
### Question 4. Check output of following in console and validate the same.
128128

129129
```
130130
console.log(2 === 2);
@@ -159,21 +159,31 @@ console.log(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
159159

160160
### Question 7. Write difference between Process and Thread.
161161

162-
A process is an instance of a program that is being executed by one or many threads. A thread is a lightweight, independent unit of execution that exists within a process. Each thread has its own program counter, stack, and local variables. Threads within the same process share the same memory space and can communicate with each other easily, while threads in different processes have separate memory spaces and must use inter-process communication (IPC) mechanisms to communicate. In short, a process is a program in execution, while a thread is a single execution sequence within that process.
162+
A process is an instance of a program that is being executed by one or many threads.
163+
164+
A thread is a lightweight, independent unit of execution that exists within a process. Each thread has its own program counter, stack, and local variables. Threads within the same process share the same memory space and can communicate with each other easily, while threads in different processes have separate memory spaces and must use inter-process communication (IPC) mechanisms to communicate.
165+
166+
In short, a process is a program in execution, while a thread is a single execution sequence within that process.
163167

164168
### Question 8. Write differences between let, const and var.
165169

166170
In JavaScript, var, let, and const are used to declare variables.
167171

172+
#### var
173+
168174
var is the oldest way to declare a variable in JavaScript. It is function-scoped, which means that a variable declared with var is only accessible within the function it was declared in, or if it is declared outside of any function, it is accessible throughout the entire script. Variables declared with var can be reassigned new values.
169175

176+
### let
177+
170178
let is similar to var, but it is block-scoped. This means that a variable declared with let is only accessible within the block it was declared in. Variables declared with let can be reassigned new values.
171179

180+
### const
181+
172182
const is also similar to let, but it is used to declare variables that cannot be reassigned new values after they are initialized. A variable declared with const is also block-scoped, so it can only be accessed within the block it was declared in.
173183

174184
In summary, var is function scoped, let and const are block scoped, let can be reassigned and const can not be reassigned.
175185

176-
### Question 9. Give 1 example of each operator with expected output
186+
### Question 9. Give one example of each operator with expected output
177187
\*\*
178188
%
179189
!=

0 commit comments

Comments
 (0)