Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

a function that calls itself js

(function(){
    for (let i = 1; i < 20; i++){
      if ((i % 2) === 0) console.log(i + ' ');
    }
  })();

//you don't have to call it, it'll just show you the result
Comment

a function that calls itself js


(function foo() { foo(); })();

Comment

js function call itself

// JavaScript Recursive Function:
// A recursive function is a function that calls itself until it doesn't.
function sumArray(array) {
  let sum = 0;
  for (const item of array) {
    sum += Array.isArray(item) ? sumArray(item) : item;
  }
  return sum;
}
sumArray([1, [4, 6]]); // => 11
Comment

PREVIOUS NEXT
Code Example
Javascript :: node version check in cmd 
Javascript :: javascript print random word from list 
Javascript :: .call javascript 
Javascript :: remove property from javascript object 
Javascript :: js array fill map 
Javascript :: how to add up all numbers in an array 
Javascript :: remove array elements javascript 
Javascript :: jquery on click function 
Javascript :: vue 3 global variable 
Javascript :: how to kill all node processes in windows 
Javascript :: how to change image source using javascript 
Javascript :: get random percentage javascript 
Javascript :: .find() is not a function 
Javascript :: p5js cdn 
Javascript :: emit resize event in angular 
Javascript :: Node.js get cpus 
Javascript :: remove duplicates from array 
Javascript :: reading files with node.js 
Javascript :: how to validate the textbox using jquery 
Javascript :: jquery validation plugin google recaptcha 
Javascript :: jquery get data attribute 
Javascript :: boilerplate node js server 
Javascript :: slickcdn 
Javascript :: upload and read json file javascript 
Javascript :: javascript spread and rest operator 
Javascript :: js document.addEventListner 
Javascript :: javascript nth root 
Javascript :: remove node_modules folder mac 
Javascript :: post data from api using jquery ajax 
Javascript :: delete a property of html by js 
ADD CONTENT
Topic
Content
Source link
Name
2+1 =