Skip to content

Commit dd62cdd

Browse files
committed
added immediate object initialization
1 parent 4c54480 commit dd62cdd

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<title>JavaScript Patterns</title>
5+
<meta charset="utf-8">
6+
</head>
7+
<body>
8+
<script>
9+
({
10+
// here you can define setting values
11+
// a.k.a. configuration constants
12+
maxwidth: 600,
13+
maxheight: 400,
14+
15+
// you can also define utility methods
16+
gimmeMax: function () {
17+
return this.maxwidth + "x" + this.maxheight;
18+
},
19+
20+
// initialize
21+
init: function () {
22+
console.log(this.gimmeMax());
23+
// more init tasks...
24+
}
25+
}).init();
26+
</script>
27+
</body>
28+
</html>

0 commit comments

Comments
 (0)