Skip to content

Commit ed251dc

Browse files
authored
Update Data-Types.md
1 parent c6e73b5 commit ed251dc

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Data-Types.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,20 @@ let newStringInstance = new String('Hello');
108108
console.log(newStringInstance instanceof String); // true
109109
```
110110

111+
#### Using `typeof` check in a function
112+
113+
```javascript
114+
function add(a, b) {
115+
if ((typeof a === 'number') && (typeof b === 'number')) {
116+
return a + b;
117+
}
118+
return -1;
119+
}
120+
121+
console.log(add('alex', 5)); // -1
122+
console.log(add(10, 5)); // 15
123+
```
124+
111125

112126
## Equality
113127

0 commit comments

Comments
 (0)