Closure:

function outer(){
	var a=1000;
	function inner(){
		console.log(a)
	}
	return inner //or put the return keyword before the function declaration
}

var v=outer();

Explanation:

Key points :

Function, along with its lexical scope, bonds together to form a closure

Example :

function x(){
	var v =10;
	function x(){
		console.log(v)
	}
	return x;
}

var res = x();
console.log(res) // it will print the x() function code
res() // it will print the 10

**(Or)**

return function x(){
	console.log(v)
}

Example_2 :

function x(){
	var v =10;
	function x(){
	  console.log(v) //500
		return v
	}
	v = 500;
	return x;
}

var res = x();
console.log(res()) //500