Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

pass a function as a parameter in other function

function map(f, a) {
  let result = []; // Create a new Array
  let i; // Declare variable
  for (i = 0; i != a.length; i++)
    result[i] = f(a[i]);
  return result;
}
const f = function(x) {
   return x * x * x;
}
let numbers = [0, 1, 2, 5, 10];
let cube = map(f,numbers);
console.log(cube);
Comment

function as an argument of another function

bool DoSomeCalculation(int a, int b, int(*Calculator)(int, int)) 
{ 
	return Calculator(a, b); 
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: asynchronous javascript 
Javascript :: mdn trimstart 
Javascript :: notification react native 
Javascript :: how to display json data in html 
Javascript :: clickable 
Javascript :: Why my array resets itself when I leave my function 
Javascript :: angular file upload 
Javascript :: search for diff in two JSON 
Javascript :: js get variable from url 
Javascript :: read more css js 
Javascript :: jquery basics 
Javascript :: mongoose virtual populate 
Javascript :: vuex store in js file 
Javascript :: web animation api keyframe options 
Javascript :: javascript get 
Javascript :: side effect, useEffect 
Javascript :: how to get last element of an array 
Javascript :: pre selected data-grid material-ui 
Javascript :: javascript object prototype 
Javascript :: how to make callback function javascript 
Javascript :: run only one test cypress 
Javascript :: javascript Adding New Elements 
Javascript :: how use multi things in in switch case in js 
Javascript :: mongodb rename property 
Javascript :: main js pass data to vue 
Javascript :: rename files in folder 
Javascript :: how to generate angular component with scss 
Javascript :: javascript join 2 variables into string 
Javascript :: try catch throwing error in javascript 
Javascript :: Angular 4 "Property does not exist on type component" 
ADD CONTENT
Topic
Content
Source link
Name
1+1 =