Javascript - Functional Programming


Code - Functional programming (FP) - Collection Operations in javascript.

All functional programming functions are array operations - See Doc


To get the cookies

console.log("Functional Programming: The cookies that we see with Javascript");

    .map(cookie => cookie.split("="))



All function returns an array.

A few returns an element such as:

  • find: returns the value of the first element in the provided array that satisfies the provided testing function.
  • findIndex() method returns the index of the first element in the array that satisfies the provided testing function.


Javascript - Map function (Functional programming)

Map example 1

data = [
  { name: 'Nicolas', firstname: 'Gerard', surname: 'nico' },
  { name: 'Rixt', firstname: 'Van Der Veen', surname: 'konigin' }

names = function (d) { return } )

firstnames = function (d) { return d.firstname } )

surnames = function (d) { return d.surname } )

Map example 2 - select and process

var myList = []'selector')) (element) {
  // ....


filter functional programming function.

Example a split on a string that does contains a separator without value create an empty string element. We filter it below.

let s = "aStringWithoutSeparator.";

console.log("With filtering");
console.log( s.split ('.').filter(el => {return el.length != 0}));

console.log("Without filtering");
console.log(s.split ('.'))


terminal function are all array function that does not produce an array such as:

Discover More
Cookie Devtool
How to manage Cookies in the Browser via Javascript?

This article is HTTP cookies management in the client side (browser) via javascript. Cookie are one way to store data in the browser. document.cookie is a property of the browser document that returns...
Javascript - Array

array in Javascript can contain any type of data. Different types of values can be stored within the same array Because arrays are special objects (as typeof implies), they can also have properties, including...
Javascript - Integer

Integer aren't implemented in javascript, only double exists. See With integers, you have to take care that all calculations fit within the range between –2^53 and 2^53, but you don’t have to worry...
Javascript - Map function (Functional programming)

The functional programming function map in a Javascript context is only an array method as all functional programming javascript method. map With an Arrow function as argument Letters that we...
Javascript - Set

The Set interface represents a set data type and works only with primitive type as there is no way to define an object equality function. object Jsdoc Declaration Add/Delete Size Contains...
Javascript - foreach instruction

How to loop with foreach in Javascript

Share this page:
Follow us:
Task Runner