---
title: "JavaScript array function"  
description: "JavaScript array function"  
author: "Anonymous User"  
published: 2018-07-16  
updated: 2018-07-16  
canonical: https://www.mindstick.com/forum/34618/javascript-array-function  
category: "web development"  
tags: ["web development", "javascript"]  
reading_time: 1 minute  

---

# JavaScript array function

How to use of [JavaScript](https://www.mindstick.com/articles/874/how-to-create-watermark-text-for-textbox-by-using-javascript) [Array](https://www.mindstick.com/articles/335/jagged-array-in-c-sharp-dot-net) [Functions](https://www.mindstick.com/forum/160140/explain-the-role-of-functions-as-a-service-faas-in-serverless-computing) ?

## Replies

### Reply by Prakash nidhi Verma

use JavaScript Array Functions :

1. prototype.reduce(): A callback function

syntax :

```
arr.reduce(callback[, initialValue])
```

ex.

```
function reduceFun1(previousValue, currentValue, index, array){     return previousValue + currentValue;
}
var result = [1,2,3,4,5].reduce(reduceFun1);

```

```
console.log(result);  
```

2. prototype.concat():

syntax :

```
NewArray = Array1.concat(value1[, value2[, ...[, valueN]]])
```

ex.

```
var arr1 = [1,2,3,4];
var arr2 = [5,6,7,8];
var arr3 = arr1.concat(arr2);
console.log(arr3);
```

\

3.prototype.sort():

syntax:

```
arr.sort([compareFunction])
```

ex.

```
var arr = [3, 1, 5, 4, 2].sort(); console.log(arr);
```

\

prototype.reverse():

syntax:

```
array.reverse()
```

ex.

```
var arr = [1,2,3,4,5,6,7,8,9,10];
arr.reverse();
console.log(arr);
```


---

Original Source: https://www.mindstick.com/forum/34618/javascript-array-function

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
