Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 6d78ae5

Browse files
Merge pull request #84 from otomer/patch-1
Update README.md (isArray)
2 parents 3709fdb + 234c129 commit 6d78ae5

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

‎README.md‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1352,6 +1352,27 @@ function(value){
13521352
}
13531353
```
13541354
1355+
**Method 4:**
1356+
1357+
You can query the constructor name:
1358+
1359+
```javascript
1360+
function isArray(value) {
1361+
return value.constructor.name === "Array";
1362+
}
1363+
1364+
```
1365+
1366+
**Method 5:**
1367+
1368+
You check if a given value is an `instanceof Array`:
1369+
1370+
```javascript
1371+
function isArray(value) {
1372+
return value instanceof Array;
1373+
}
1374+
```
1375+
13551376
## Question 37. Best way to detect reference values of any type in JavaScript ?
13561377
13571378
In Javascript Object are called as reference type, Any value other then primitive is definitely a reference type. There are several built-in reference type such as **Object**, **Array**, **Function**, **Date**, **null** and **Error**.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /