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 :: javascript array every 
Javascript :: express docs 
Javascript :: how to add header to axios request 
Javascript :: do while 
Javascript :: get 3 random items from array javascript 
Javascript :: regex for erlang online 
Javascript :: menu with dynamic submenu in javascript 
Javascript :: d3 js date scatter plot 
Javascript :: decode jwt token online 
Javascript :: html select structure 
Javascript :: lookup objects 
Javascript :: remove a key/value mongo 
Javascript :: $( ) jquery 
Javascript :: object wrappers in javascript 
Javascript :: sort used in price high and low using angular 
Javascript :: how to put condition on pagination material table 
Javascript :: user key value within the obj js 
Javascript :: Multiple Locale Support momentjs 
Javascript :: Javascript - Dependency between arguments of partial applications 
Javascript :: angularjs Indicators and Paginator styling for PrimeNG Carousel 
Javascript :: angularjs How to render either a number or a HTML element depending on what a function returns 
Javascript :: angular chart js graph legend colors 
Javascript :: Navigating to another Screen when a button is tapped in React Native 
Javascript :: socket io check send 
Javascript :: reduce dot notations to javascript array 
Javascript :: remember me option in firebase + react 
Javascript :: jquery event element in viewport 
Javascript :: Importing Ky Module In JavaScript 
Javascript :: how to have two entry files in webpack 
Javascript :: wait for element to be loaded 
ADD CONTENT
Topic
Content
Source link
Name
6+9 =