Skip to content

Instantly share code, notes, and snippets.

@Sljubura
Last active December 22, 2015 20:38
Show Gist options
  • Save Sljubura/6527495 to your computer and use it in GitHub Desktop.
Save Sljubura/6527495 to your computer and use it in GitHub Desktop.
Jednostavan prikaz closure-a.
function pdv(OPERACIJA) {
return function (broj) {
if ( OPERACIJA === '-' ) {
return broj - 20;
} else if( OPERACIJA === '+' ) {
return broj + 20;
} else {
throw 'Lose uneti parametri!';
}
}
}
var oduzmi = pdv('-');
var hiljadu = oduzmi(1000);
console.log(hiljadu);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment