# I have an some Doubt Array Topic

**URL:** <https://forum.codewithmosh.com/t/i-have-an-some-doubt-array-topic/27986>\
**Category:** JavaScript\
**Created:** [July 31, 2024, 7:19am UTC](https://forum.codewithmosh.com/t/i-have-an-some-doubt-array-topic/27986 "2024-07-31T07:19:54Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![sivakumar](https://avatars.discourse-cdn.com/v4/letter/s/bb73d2/32.png) [@sivakumar](https://forum.codewithmosh.com/u/sivakumar)\
**Post date:** [July 31, 2024, 7:19am UTC](https://forum.codewithmosh.com/t/i-have-an-some-doubt-array-topic/27986/1 "2024-07-31T07:19:54Z")

</div>

Hi,

I am using array method but i have some doubt… when did i use call back function and return keyword… can you please tell me… another doubt i am using array and i have to push some value in array… then why can’t stored in variable in push method i have attached snapshot please see…  
 ![Doubt](https://us1.discourse-cdn.com/flex020/uploads/codewithmosh/original/2X/8/8e632647ce976e73ce035f533766b4ee988a5024.png)

---

<div class="post-metadata">

**Author:** ![sufian.babri](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/sufian.babri/32/1028_2.png) [@sufian.babri](https://forum.codewithmosh.com/u/sufian.babri)\
**Post date:** [August 5, 2024, 7:22pm UTC](https://forum.codewithmosh.com/t/i-have-an-some-doubt-array-topic/27986/2 "2024-08-05T19:22:45Z")

</div>

If I understand your first question correctly, you want to know when to use return in an arrow callback function.

The answer is that if you wrap your function body in curly braces then you have to write “return”, otherwise not.

```auto
const callback = (v) => v === "John";

const another = (v) => {
    return v === "John";
} 

```

I think your second question is about the value returned by the array’s push function. This function modified the array by inserting the element and returns its new length. You can see the [docs here](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/push).

---

<div class="post-metadata">

**Author:** ![sivakumar](https://avatars.discourse-cdn.com/v4/letter/s/bb73d2/32.png) [@sivakumar](https://forum.codewithmosh.com/u/sivakumar)\
**Post date:** [August 6, 2024, 4:04pm UTC](https://forum.codewithmosh.com/t/i-have-an-some-doubt-array-topic/27986/3 "2024-08-06T16:04:33Z")

</div>

when I use callback function in array methods?

---

<div class="post-metadata">

**Author:** ![sufian.babri](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/sufian.babri/32/1028_2.png) [@sufian.babri](https://forum.codewithmosh.com/u/sufian.babri)\
**Post date:** [August 6, 2024, 10:55pm UTC](https://forum.codewithmosh.com/t/i-have-an-some-doubt-array-topic/27986/4 "2024-08-06T22:55:51Z")

</div>

You can use arrow functions with Array.sort, Array.find, etc.

---

<div class="post-metadata">

**Author:** ![sivakumar](https://avatars.discourse-cdn.com/v4/letter/s/bb73d2/32.png) [@sivakumar](https://forum.codewithmosh.com/u/sivakumar)\
**Post date:** [August 7, 2024, 7:22pm UTC](https://forum.codewithmosh.com/t/i-have-an-some-doubt-array-topic/27986/5 "2024-08-07T19:22:11Z")

</div>

Yes, but i don’t know how to find use arrow function in paricular methods… is there any hints

---

<div class="post-metadata">

**Author:** ![sufian.babri](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/sufian.babri/32/1028_2.png) [@sufian.babri](https://forum.codewithmosh.com/u/sufian.babri)\
**Post date:** [August 8, 2024, 11:13am UTC](https://forum.codewithmosh.com/t/i-have-an-some-doubt-array-topic/27986/6 "2024-08-08T11:13:28Z")

</div>

It’s simple. Callback using a traditional function:

```auto
const numbers = [1, 2, 3, 4, 5];
const findNumber = numbers.find(function (number) {
  return number > 3;
});

```

Callback using an arrow function:

```auto
const numbers = [1, 2, 3, 4, 5];
const findNumber = numbers.find((number) => number > 3);

```

---

<div class="post-metadata">

**Author:** ![sivakumar](https://avatars.discourse-cdn.com/v4/letter/s/bb73d2/32.png) [@sivakumar](https://forum.codewithmosh.com/u/sivakumar)\
**Post date:** [August 9, 2024, 9:59am UTC](https://forum.codewithmosh.com/t/i-have-an-some-doubt-array-topic/27986/7 "2024-08-09T09:59:28Z")

</div>

i think totally 32 array methods… can you please tell me which array method using only call back function…

---

<div class="post-metadata">

**Author:** ![sufian.babri](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/sufian.babri/32/1028_2.png) [@sufian.babri](https://forum.codewithmosh.com/u/sufian.babri)\
**Post date:** [August 10, 2024, 8:13pm UTC](https://forum.codewithmosh.com/t/i-have-an-some-doubt-array-topic/27986/8 "2024-08-10T20:13:08Z")

</div>

Are you asking which array functions only accept the traditional function syntax? Is this your question?
