# Pure Function

Pure function gives certain output every time, If we give certain input as argument. Functions which don’t get affected by any outer piece of code are pure functions.

Example:

#### Pure Function

var getSquare = function(x){

return x*x;

}

If we call the above function and pass a argument X (a number) always get a square of X.

#### Impure function

var x = 8;

var getSquare = function(){

return x*x;

}

In the above function we use a global variable inside function so function’s output depends on the global variable value. If we call the above function and pass argument the output will be 64 every time.