Closure scope vs. Object scope

August 18, 2017

function outer() {
	var one = 1;
	var two = 2;

	return function inner(){
		return one + two;
	};
}

const three = outer();

three();			// 3

And an illustration of a simple object:

const obj = {
	one: 1,
	two: 2
};

function three(outer) {
	return outer.one + outer.two;
}

three( obj );		// 3

Tagged withjavascript, functional programming

Questions, Comments, Suggestions? Open an Issue