JS Functions

This are the Verbs that make the action happen on JS, and are one of the fundamental building blocs in JS. to use a function you must define it somewhere in the scope from which you wish to call it, now lest see some examples on how this works.

Definition and use:

Functions inside Arrays

Functions inside Objects

Two Different ways to declare a Function???

Not Really, One is call: Function Expression and the other is Function Declaration Statement, the main difference that function expressions are not hoisted:

           Function expression hoisting

Function expressions in JavaScript are not hoisted, unlike function declarations. You can’t use function expressions before you declare them:


higherorder function

In mathematics and computer science, a higherorder function (also functional,functional form or functor) is a function that does at least one of the following:

  • Takes one or more functions as arguments (i.e., procedural parameters)
  • Returns afunction as its result.

Functional Programming:

In computer science, functional programming is a programming paradigm “style” of building the structure and elements of computer programs—that treats computation as the evaluation of mathematical functions and avoids changing-state and mutable data.

Basically is a style, that when we need to create a BIG program that does several little things, we create a Little-Function that does each of those little thing lest call them Minion-Functions, we also create another Master-Function that decided which of the little ones to use, if we need to add one more feature to the Big program we only create a new little Minion Functions, and when we need to change the process on one of the already created little Minion Function we edit that little one and nothing else.  this is a very basic explanation if you wan to understand better: Link1  –  Link2  –  Link3  –  Link4

Nested Functions


A closure is an inner function that has access to the outer (enclosing) function’s variables—scope chain. The closure has three scope chains: it has access to its own scope (variables defined between its curly brackets), it has access to the outer function’s variables, and it has access to the global variables.   To get a better understanding please read my Blog-Post:  Closures.

JavaScript Built-In Functions

JavaScript is a language, and like other languages it has words that have deeper meaning, one example is:

We do not say: “I took, chew, swallow, and ingest bite by bite that Hamburger”

We usually say: “I ate that Hamburger”


In javaScript we also have some words that have a more deep meaning, and in some cases they can take a parameter, process it, and provide a different product, some of this are call Build-In Functions;

here is a list of some of those functions: JavaScript Build-In Functions.


ES6 Functions

Here we have the fat arrow way to write functions.

we have new functionality like default value in parameters when parameters are not passed.

When passing parameters, remember ” Undefined “ will trigger the default value but ” Null “ is a valid parameter value and will not make use of the default parameter value.



Copyright 2017. All rights reserved.

Posted January 23, 2017 by Edmundo in category "JS