Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Higher order function javascript

//Syntactic Sugar for a ForEach loop below; this is part of a form validation
//and basicly goes through every element in the form and logs the id for said
//element. 

function checkRequired(inputArr) {
  //   		|   
  //?       V   High Order Array Method 
  inputArr.forEach(function (input) {
    console.log(input.id)  
  });
}

//! Event Listeners --> This is a higher order functon
form.addEventListener('submit', function (e) {
  e.preventDefault();
  //passing in array of arguments to be checked
  checkRequired([username, email, password, password2]); 
});
Source by www.google.com #
 
PREVIOUS NEXT
Tagged: #Higher #order #function #javascript
ADD COMMENT
Topic
Name
7+5 =