2
2
<a href =" /README.md#this-is-a-collection-of-modern-interview-code-challenges-on-javascript-suitable-for " id =" home " >Home</a >
3
3
</div >
4
4
5
- ## JavaScript interview code challenges on Primitives - concepts
6
-
7
- 1 . [ Show the usage of ` typeof ` operator on different types of values] ( #Q1 )
8
- 1 . [ Show the different ways of concatenating numbers and strings] ( #Q2 )
9
- 1 . [ Show the conversion from number to string and vice versa] ( #Q3 )
10
- 1 . [ Write a code to operate on integer numbers outside the range of numbers in JavaScript] ( #Q4 )
11
- 1 . [ Show the usage of ` || ` , ` && ` , ` ?? ` and ` !! ` with code examples] ( #Q5 )
12
- 1 . [ Show the frequently and commonly used methods available on ` Number ` object with coding examples] ( #Q6 )
13
- 1 . [ Write the polyfill for ` Number.isNaN ` ] ( #Q7 )
14
- 1 . [ Show the frequently and commonly used methods available on ` Math ` object with coding examples] ( #Q8 )
15
- 1 . [ How can we solve the problem of comparision of 0.1 + 0.2 with 0.3 where ` === ` operator fails] ( #Q9 )
16
- 1 . [ Write a code to iterate over a string] ( #Q10 )
17
- 1 . [ Show the usage of template literals, expression interpolation and tagged templates] ( #Q11 )
18
- 1 . [ Write a code to show the working of ` try...catch...finally ` ] ( #Q12 )
19
- 1 . [ Show the creation and usage of ` symbol ` with code] ( #Q13 )
20
-
21
- ---
22
-
23
- #### Q1
24
- ### Show the usage of ` typeof ` operator on different types of values
5
+ <h2 align =" center " >JavaScript interview code challenges on Primitives - concepts</h2 >
6
+
7
+ <br >
8
+
9
+ ### Q. Show the usage of ` typeof ` operator on different types of values
25
10
26
11
- The ` typeof ` operator returns a string indicating the type of the operand
27
12
@@ -51,8 +36,8 @@ Arrays and functions are sub type of objects
51
36
52
37
<br />
53
38
54
- #### Q2
55
- ### Show the different ways of concatenating numbers and strings
39
+
40
+ ### Q. Show the different ways of concatenating numbers and strings
56
41
57
42
- Concatenation of strings and numbers is a common practical use case
58
43
@@ -81,8 +66,8 @@ Arrays and functions are sub type of objects
81
66
82
67
<br />
83
68
84
- #### Q3
85
- ### Show the conversion from number to string and vice versa
69
+
70
+ ### Q. Show the conversion from number to string and vice versa
86
71
87
72
- Conversion between numbers and strings is a common practical use case
88
73
@@ -112,8 +97,8 @@ If the number is floating, `parseFloat` can be used. `parseInt` and `parseFloat`
112
97
113
98
<br />
114
99
115
- #### Q4
116
- ### Write a code to operate on integer numbers outside the range of numbers in JavaScript
100
+
101
+ ### Q. Write a code to operate on integer numbers outside the range of numbers in JavaScript
117
102
118
103
- ` BigInt ` is a datatype in JavaScript which facilitates the mathematical opertions on huge value of integer number
119
104
- It is represented by a suffix 'n' for number value
@@ -135,8 +120,8 @@ The big integers cannot be operated directly with normal number datatype. `10n +
135
120
136
121
<br />
137
122
138
- #### Q5
139
- ### Show the usage of ` || ` , ` && ` , ` ?? ` and ` !! ` with code examples
123
+
124
+ ### Q. Show the usage of ` || ` , ` && ` , ` ?? ` and ` !! ` with code examples
140
125
141
126
- The __ logical OR__ (||) operator for a set of operands is true if and only if one or more of its operands is true
142
127
- The __ logical AND__ (&&) operator for a set of operands is true if and only if all of its operands are true
@@ -190,8 +175,8 @@ It is not possible to combine both the AND (&&) and OR operators (||) directly w
190
175
191
176
<br />
192
177
193
- #### Q6
194
- ### Show the frequently and commonly used methods available on ` Number ` object with coding examples
178
+
179
+ ### Q. Show the frequently and commonly used methods available on ` Number ` object with coding examples
195
180
196
181
- ` isInteger` is used to check if the given number is integer or not
197
182
- ` parseInt` is used to convert a given value in to integer
@@ -231,8 +216,8 @@ Number.isNaN("text"); // false
231
216
232
217
<br />
233
218
234
- #### Q7
235
- ### Write the polyfill for ` Number .isNaN `
219
+
220
+ ### Q. Write the polyfill for ` Number .isNaN `
236
221
237
222
- A polyfill is a piece of code used to provide modern functionality on older browsers that do not natively support it
238
223
- ` NaN ` is the only value which is not equal to itself and hence comparision operator cannot be used directly to check if a value is ` NaN `
@@ -251,8 +236,8 @@ Even though the name says _Not a Number_, it is of type "number"
251
236
252
237
<br />
253
238
254
- #### Q8
255
- ### Show the frequently and commonly used methods available on ` Math ` object with coding examples
239
+
240
+ ### Q. Show the frequently and commonly used methods available on ` Math ` object with coding examples
256
241
257
242
- ` abs` is used to get the absolute value of the given number
258
243
- ` floor` is used to get the greatest integer smaller than or equal to the given number
@@ -281,8 +266,8 @@ Math.trunc(-6.3)); // -6
281
266
282
267
<br />
283
268
284
- #### Q9
285
- ### How can we solve the problem of comparision of 0.1 + 0.2 with 0.3 where ` === ` operator fails
269
+
270
+ ### Q. How can we solve the problem of comparision of 0.1 + 0.2 with 0.3 where ` === ` operator fails
286
271
287
272
- The addition of 0.1 and 0.2 will result in to 0.30000000000000004 and the comparision with 0.3 fails
288
273
- ` Number .epsilon ` is 2<sup>-52</sup>, which can be used to verify if this decimal values are matching
@@ -296,8 +281,8 @@ Math.trunc(-6.3)); // -6
296
281
297
282
<br />
298
283
299
- #### Q10
300
- ### Write a code to iterate over a string
284
+
285
+ ### Q. Write a code to iterate over a string
301
286
302
287
- String can be traversed using its string index or value as string can act like an iterable
303
288
@@ -328,8 +313,8 @@ for(let value of str){
328
313
329
314
<br />
330
315
331
- #### Q11
332
- ### Show the usage of template literals with expression interpolation and tagged templates
316
+
317
+ ### Q. Show the usage of template literals with expression interpolation and tagged templates
333
318
334
319
- Template literals are string literals allowing embedded expressions and support multi lines
335
320
- Template literals are enclosed by the backtick \`
@@ -364,8 +349,8 @@ myTag`Note: ${person} is a member of following communities: ${membership}`;
364
349
365
350
<br />
366
351
367
- #### Q12
368
- ### Write a code to show the working of ` try ... catch... finally`
352
+
353
+ ### Q. Write a code to show the working of ` try ... catch... finally`
369
354
370
355
- The ` try ` statement consists of a try-block, which contains one or more statements. At least one catch-block, or a finally-block, must be present
371
356
- The exceptions and errors from try block are caught in catch block
@@ -391,8 +376,8 @@ try {
391
376
392
377
<br />
393
378
394
- #### Q13
395
- ### Show the creation and usage of ` symbol` with code
379
+
380
+ ### Q. Show the creation and usage of ` symbol` with code
396
381
397
382
- A "symbol" represents a unique identifier
398
383
- ` Symbol .for ` method searches for existing symbols in a runtime-wide symbol registry returns the same. If not found, creates a new Symbol
0 commit comments