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: _posts/2020-04-11-Commonly used JavaScript functions.markdown
+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
@@ -1,7 +1,7 @@
1
1
---
2
2
layout: post
3
3
title: "Commonly used JavaScript String, Array, and Object methods"
4
-
date: 2019-11-28 10:00:00 +0530
4
+
date: 2020-04-11 16:00:00 -0700
5
5
tags: [JavaScript, functions, methods]
6
6
comments: true
7
7
---
@@ -34,14 +34,14 @@ Following are some of the common methods from the [Array][Array] global object.
34
34
35
35
Just like with `String` methods, use `indexOf()` if you need the position of the value in the array. Use `includes()` if you are only concerned whether the value exists, it makes intent of the code more clear.
36
36
37
-
`indexOf()` and `includes()` use [strict equality][Strict equality] (the same method used by the === or triple-equals operator) for comparing the search element with the elements of the Array. So, when used on an array containing objects, object references are compared not the actual values.
37
+
`indexOf()` and `includes()` use [strict equality][Strict equality] (the same method used by the triple-equals operator ===) for comparing the search element with the elements of the Array. So, when used on an array containing objects, object references are compared not the actual values.
38
38
39
39
Therefore, when dealing with array of objects, use `some()`, `find()`, or `findIndex()` methods.
40
40
41
41
-[find()][Array.prototype.find()] - This method returns the value of the first element in the array that satisfies the provided testing function. Otherwise, `undefined` is returned.
42
42
-[findIndex()][Array.prototype.findIndex()] - This method returns the index of the first element in the array that satisfies the provided testing function. Otherwise, it returns -1.
43
43
-[some()][Array.prototype.some()] - This method tests whether **at least one element** in the array passes the test implemented by the provided function. It returns _true_ or _false_ appropriately.
44
-
-[every()][Array.prototype.every()] - This method tests whether **all elements** in the array passes the test implemented by the provided function. It returns _true_ or _false_ appropriately.
44
+
-[every()][Array.prototype.every()] - This method tests whether **all elements** in the array pass the test implemented by the provided function. It returns _true_ or _false_ appropriately.
45
45
46
46
Following methods are used for filtering and transforming an array.
0 commit comments