JavaScript Jargon: 10 Terms You Should Know

var add4 = addx(4); console.log(add4(8)); //12 console.log(add4(6)); //10 console.log(add4(-74)); //-70

Now, the former function suddenly gets interesting. Since in currying multiple functions inside one another act like steps in a sequence of operation taking one or few variables at a time, a single step can be fixed and start from it the rest of the steps with the rest of the variables.

The following function has an arity of 3.

  1. Arity
  2. Anonymous
  3. Closure
  4. Currying
  5. Hoisting
  6. Mutation
  7. Pragma
  8. Sentinel
  9. Vanilla
  10. Variadic

arity, of the Function object that returns the number of expected arguments in a function. It is now obsolete though and replaced by length.

var foo = function() { };

That is also said to be an anonymous function since there is no name after the key word function.

"use strict";

By the above pragma, the JavaScript code will be executed in strict mode. In strict mode, bad syntax is not allowed, hoisting is not done, silent errors are shown, etc. It helps in writing a more secure and optimized JavaScript code.

The function add simply takes both x and y at the same time, performs the addition and returns the sum. So far the first function might not seem very useful, until…

function getName(first, middle, last){ return first+' '+ middle +' '+last; }

IIFE (Immediately Invoked Function Expression). The function in it is anonymous since it doesn’t have a name. Now, take a look at the one below.

It’s like we christened a nameless function with the name ‘foo’ and called it using that. Does that count as anonymous? I don’t know, I’ll leave that to the English experts. But, my confusion aside, they both are indeed referred to as anonymous function.

Haskell Curry, refers to using multiple functions with single arguments, in place of a single function with multiple arguments. Let’s see the add functions below for example.

A little bit of doubt rises in the correctness of the use of the word "anonymous". With IIFE, the function gets called right away, no name involved whereas, to call the latter function the syntax foo() is used.

function addx(x){ function addy(y){ return x+y; } return addy } function add(x,y){ return(x+y); } console.log(addx(3)(4)); \\7 console.log(add(3,4)); \\7

Both of the functions return the same result. The function addx accepts a parameter x while returning addy which in turn accepts the y value, performs the addition with x and returns the sum.

This post is the compilation of 10 such terms with their meaning and the context in which they are used in JavaScript. If you’re a beginner then this list has got you covered with the basics like hoisting. At the same time less-known or less-understood terms are also included in there.

MutationObserver in my post.)

few pragmas, one of them is strict.

From currying to closures there are quite a number of JavaScript jargons (special words used within the field) knowing which will not only help you increase your vocabulary but understand JavaScript better. Jargons are normally found in documentations and technical articles. But some of them like closures are pretty standard things to know about. Knowing what the word itself mean can help you know the concept it is named for better.

Leave a Reply