Skip to content

Commit f7ddb9a

Browse files
authored
Merge pull request #291 from subhoghoshX/fix
Miscellaneous fixes
2 parents 05ed546 + feb4fd4 commit f7ddb9a

File tree

1 file changed

+28
-21
lines changed

1 file changed

+28
-21
lines changed

README.md

+28-21
Original file line numberDiff line numberDiff line change
@@ -3077,12 +3077,12 @@
30773077
1. [abc]: Used to find any of the characters between the brackets(a,b,c)
30783078
2. [0-9]: Used to find any of the digits between the brackets
30793079
3. (a|b): Used to find any of the alternatives separated with |
3080-
2. **Metacharacters:** These are characters with a special meaning
3080+
2. **Metacharacters:** These are characters with a special meaning.
30813081
For example, below are some use cases,
30823082
1. \\d: Used to find a digit
30833083
2. \\s: Used to find a whitespace character
30843084
3. \\b: Used to find a match at the beginning or ending of a word
3085-
3. **Quantifiers:** These are useful to define quantities
3085+
3. **Quantifiers:** These are useful to define quantities.
30863086
For example, below are some use cases,
30873087
1. n+: Used to find matches for any string that contains at least one n
30883088
2. n\*: Used to find matches for any string that contains zero or more occurrences of n
@@ -3554,7 +3554,7 @@
35543554
35553555
console.log(sum(1, 2)); //3
35563556
console.log(sum(1, 2, 3)); //6
3557-
console.log(sum(1, 2, 3, 4)); //13
3557+
console.log(sum(1, 2, 3, 4)); //10
35583558
console.log(sum(1, 2, 3, 4, 5)); //15
35593559
```
35603560

@@ -4338,9 +4338,10 @@
43384338

43394339
228. ### What are the different error names from error object
43404340

4341-
There are 6 different types of error names returned from error object,
4341+
There are 7 different types of error names returned from error object,
43424342
| Error Name | Description |
43434343
|---- | ---------
4344+
| AggregateError | An error indicating that multiple errors occurred |
43444345
| EvalError | An error has occurred in the eval() function |
43454346
| RangeError | An error has occurred with a number "out of range" |
43464347
| ReferenceError | An error due to an illegal reference|
@@ -5345,7 +5346,7 @@
53455346
namespaceTwo.func1(); // This is a second definition
53465347
```
53475348

5348-
1. **Using IIFE (Immediately invoked function expression):** The outer pair of parentheses of IIFE creates a local scope for all the code inside of it and makes the anonymous function a function expression. Due to that, you can create the same function in two different function expressions to act as a namespace.
5349+
2. **Using IIFE (Immediately invoked function expression):** The outer pair of parentheses of IIFE creates a local scope for all the code inside of it and makes the anonymous function a function expression. Due to that, you can create the same function in two different function expressions to act as a namespace.
53495350

53505351
```javascript
53515352
(function () {
@@ -5363,7 +5364,7 @@
53635364
})();
53645365
```
53655366

5366-
1. **Using a block and a let/const declaration:** In ECMAScript 6, you can simply use a block and a let declaration to restrict the scope of a variable to a block.
5367+
3. **Using a block and a let/const declaration:** In ECMAScript 6, you can simply use a block and a let declaration to restrict the scope of a variable to a block.
53675368

53685369
```javascript
53695370
{
@@ -5564,7 +5565,7 @@
55645565

55655566
The output of the above for loops is 4 4 4 4 and 0 1 2 3
55665567

5567-
**Explanation:** Due to the event queue/loop of javascript, the `setTimeout` callback function is called after the loop has been executed. Since the variable i is declared with the `var` keyword it became a global variable and the value was equal to 4 using iteration when the time `setTimeout` function is invoked. Hence, the output of the first loop is `4 4 4 4`.
5568+
**Explanation:** Due to the event queue/loop of javascript, the `setTimeout` callback function is called after the loop has been executed. Since the variable i is declared with the `var` keyword it became a global variable and the value was equal to 4 using iteration when the time `setTimeout` function is invoked. Hence, the output of the second loop is `4 4 4 4`.
55685569

55695570
Whereas in the second loop, the variable i is declared as the `let` keyword it becomes a block scoped variable and it holds a new value(0, 1 ,2 3) for each iteration. Hence, the output of the first loop is `0 1 2 3`.
55705571

@@ -5925,16 +5926,20 @@
59255926
59265927
320. ### What are typed arrays
59275928
5928-
Typed arrays are array-like objects from ECMAScript 6 API for handling binary data. JavaScript provides 8 Typed array types,
5929+
Typed arrays are array-like objects from ECMAScript 6 API for handling binary data. JavaScript provides 12 Typed array types,
59295930
59305931
1. Int8Array: An array of 8-bit signed integers
5931-
2. Int16Array: An array of 16-bit signed integers
5932-
3. Int32Array: An array of 32-bit signed integers
5933-
4. Uint8Array: An array of 8-bit unsigned integers
5932+
2. Uint8Array: An array of 8-bit unsigned integers
5933+
3. Uint8ClampedArray: An array of 8-bit unsigned integers clamped to 0-255
5934+
4. Int16Array: An array of 16-bit signed integers
59345935
5. Uint16Array: An array of 16-bit unsigned integers
5935-
6. Uint32Array: An array of 32-bit unsigned integers
5936-
7. Float32Array: An array of 32-bit floating point numbers
5937-
8. Float64Array: An array of 64-bit floating point numbers
5936+
6. Int32Array: An array of 32-bit signed integers
5937+
7. Uint32Array: An array of 32-bit unsigned integers
5938+
8. BigInt64Array: An array of 64-bit signed BigInts
5939+
9. BigUint64Array: An array of 64-bit unsigned BigInts
5940+
10. Float16Array: An array of 16-bit floating point numbers
5941+
11. Float32Array: An array of 32-bit floating point numbers
5942+
12. Float64Array: An array of 64-bit floating point numbers
59385943
59395944
For example, you can create an array of 8-bit signed integers as below
59405945
@@ -6006,7 +6011,8 @@
60066011
[..."John Resig"];
60076012
```
60086013
6009-
The output of the array is ['J', 'o', 'h', 'n', '', 'R', 'e', 's', 'i', 'g']
6014+
The output of the array is ['J', 'o', 'h', 'n', ' ', 'R', 'e', 's', 'i', 'g']
6015+
60106016
**Explanation:** The string is an iterable type and the spread operator within an array maps every character of an iterable to one element. Hence, each character of a string becomes an element within an Array.
60116017
60126018
**[⬆ Back to Top](#table-of-contents)**
@@ -6193,12 +6199,13 @@
61936199
2. When you use delete operator on a variable name
61946200
3. Using eval or arguments as variable or function argument name
61956201
4. When you use newly reserved keywords
6196-
5. When you declare a function in a block
6202+
5. When you declare a function in a block and access it from outside of the block
61976203
61986204
```javascript
61996205
if (someCondition) {
62006206
function f() {}
62016207
}
6208+
f(); // ReferenceError: f is not defined
62026209
```
62036210
62046211
Hence, the errors from above cases are helpful to avoid errors in development/production environments.
@@ -6207,7 +6214,7 @@
62076214
62086215
341. ### Do all objects have prototypes
62096216
6210-
No. All objects have prototypes except for the base object which is created by the user, or an object that is created using the new keyword.
6217+
No. All objects have prototypes except the base object or an object created with Object.create(null) method. The base object is Object.prototype, and its prototype is null.
62116218
62126219
**[⬆ Back to Top](#table-of-contents)**
62136220
@@ -7694,7 +7701,7 @@
76947701

76957702
// key are the property keys
76967703
for (let key in arr) {
7697-
console.log(key); // 0, 1, 2 & newValue
7704+
console.log(key); // 0, 1, 2 & newProp
76987705
}
76997706

77007707
// value are the property values
@@ -7756,9 +7763,9 @@
77567763
Since both IIFE and void operator discard the result of an expression, you can avoid the extra brackets using `void operator` for IIFE as below,
77577764
77587765
```js
7759-
void (function (dt) {
7766+
void function (dt) {
77607767
console.log(dt.toLocaleTimeString());
7761-
})(new Date());
7768+
}(new Date());
77627769
```
77637770
77647771
**[⬆ Back to Top](#table-of-contents)**
@@ -8478,7 +8485,7 @@ The execution context is created when a function is called. The function's code
84788485
There are several built-in higher order functions exists on arrays, strings, DOM and promise methods in javascript. These higher order functions provides significant level of abstraction. The list of functions on these categories are listed below,
84798486
1. **arrays:** map, filter, reduce, sort, forEach, some etc.
84808487
2. **DOM**: The DOM method `element.addEventListener(type, handler)` also accepts the function handler as a second argument.
8481-
3. **Strings:** .some() method
8488+
3. **Strings:** replace() method.
84828489
84838490
84848491
**[⬆ Back to Top](#table-of-contents)**

0 commit comments

Comments
 (0)