forked from HackYourFuture/JavaScript1
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclosure2.js
More file actions
19 lines (18 loc) · 459 Bytes
/
closure2.js
File metadata and controls
19 lines (18 loc) · 459 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
'use strict';
/**
* Closure returning an object
*/
function someoneNamed(name) {
var obj = {
getName: function() {
return name;
},
getNameUpper: function() {
return name.toUpperCase();
}
};
return obj;
}
var someOtherGuy = someoneNamed('Hasan');
var thisGuy = someoneNamed("jim");
console.log('Hey, ' + someOtherGuy.getName() + '... Are you there ' + someOtherGuy.getNameUpper() + '?');