-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcalc.js
More file actions
56 lines (40 loc) · 1.03 KB
/
calc.js
File metadata and controls
56 lines (40 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
'use strict'
// IMMEDIATELY INVOKED FUNCTION EXPRESSION
// used for privatising scope and not having global vars. For when one instance is enough.
// brackets are needed to force the parser to parse the function as an expression, not a declaration
// new Calc() is not used here - this is used for creating an instance of a 'class'
var Calc = (function() {
var data = {
mem: 0
}
var container;
var build = function() {
$(container).on('click', ".add", function(event){
event.preventDefault();
console.log('add')
});
$(container).on('click', ".minus", function(event){
event.preventDefault();
console.log('minus')
});
}
var loop = function() {
var a, i, j, len;
a = [1, 2, 3];
for (j = 0, len = a.length; j < len; j++) {
i = a[j];
alert(i);
}
//coffeescript
// a = [1,2,3]
// for i in a
// alert(i)
}
return {
init: function(_container) {
container = _container;
build();
}
};
})();
Calc.init($('#calculator'));