Writing Arrow Functions with Parameters

you can pass parameters to arrow functions as well as shown in the following demo, these functions are only meant to be used once where normal functions can be re-used.


function run_function() {
  "use strict";
  const double_me = (item) => item * 2;
  return double_me(2);

// write this function in one line example
var myConcat = function(arr1, arr2) {
  "use strict";
  return arr1.concat(arr2);

"use strict";
const myConcat = (arr1, arr2) => arr1.concat(arr2);
console.log(myConcat([1, 2], [3, 4, 5]));

// this is a common function just to write the content into the result div
function write_result(result) {
  var result_html = document.getElementById("result");
  result_html.innerHTML = result;


<div id='result' class='mb-3 alert alert-primary'>..</div>
<button onclick='run_function();' class='btn btn-primary mb-1'>Run Function</button>

Working Result


External Link for Writing Arrow Functions with Parameters

Other Items in javascript
Page Views

This page has been viewed 355 times.

Search Code
Search Code by entering your search text above.

This is my test area for webdev. I keep a collection of code snippits here, mostly for my reference. Also if i find a good site, i usually add it here.


Random Quote
Old programmers never die; they just lose some of their functions.