You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -261,7 +261,7 @@ The best way to find whether an object is instance of a particular class or not
261
261
var arrayList = [1 , 2, 3];
262
262
```
263
263
264
-
One of the best use cases of type checking of an object is when we do method overloading in JavaScript. For understanding this let say we have a method called `greet` which take one single string and also a list of string, so making our `greet` method workable in both situation we need to know what kind of parameter is being passed, is it single value or list of value?
264
+
One of the best use cases of type checking of an object is when we do method overloading in JavaScript. To understand this, let's say we have a method called `greet` which can take a single string and also a list of strings. To make our `greet` method workable in both situation we need to know what kind of parameter is being passed: is it single value or list of values?
265
265
266
266
```javascript
267
267
functiongreet(param) {
@@ -273,7 +273,7 @@ function greet(param) {
273
273
}
274
274
```
275
275
276
-
However, in above implementation it might not necessary to check the type of the array, we can check for single value string and put array logic code in else block, let see below code for the same.
276
+
However, in the above implementation it might not necessary to check the type of the array, we can check for single value string and put array logic code in else block, let see below code for the same.
277
277
278
278
```javascript
279
279
functiongreet(param) {
@@ -285,7 +285,7 @@ However, in above implementation it might not necessary to check the type of the
285
285
}
286
286
```
287
287
288
-
Now it's fine we can go with above two implementations, but when we have a situation like a parameter can be `single value`, `array`, and `object` type then we will be in trouble.
288
+
Now it's fine we can go with the previous two implementations, but when we have a situation like a parameter can be `single value`, `array`, and `object` type then we will be in trouble.
289
289
290
290
Coming back to checking the type of an object, As we mentioned that we can use `Object.prototype.toString`
0 commit comments