Permalink
Browse files

added immediate object initialization

  • Loading branch information...
1 parent 4c54480 commit dd62cddb59d868986191616ad3c9692c8eb70dd9 @shichuan shichuan committed Dec 24, 2011
Showing with 28 additions and 0 deletions.
  1. +28 −0 functions/immediate-object-initialization.html
View
28 functions/immediate-object-initialization.html
@@ -0,0 +1,28 @@
+<!doctype html>
+<html lang="en">
+<head>
+<title>JavaScript Patterns</title>
+<meta charset="utf-8">
+</head>
+<body>
+<script>
+({
+ // here you can define setting values
+ // a.k.a. configuration constants
+ maxwidth: 600,
+ maxheight: 400,
+
+ // you can also define utility methods
+ gimmeMax: function () {
+ return this.maxwidth + "x" + this.maxheight;
+ },
+
+ // initialize
+ init: function () {
+ console.log(this.gimmeMax());
+ // more init tasks...
+ }
+}).init();
+</script>
+</body>
+</html>

0 comments on commit dd62cdd

Please sign in to comment.