PageRenderTime 25ms CodeModel.GetById 21ms app.highlight 3ms RepoModel.GetById 0ms app.codeStats 0ms

/pedantic/lesson.js

http://github.com/coolaj86/node-examples-js
JavaScript | 75 lines | 55 code | 20 blank | 0 comment | 0 complexity | 2f1d6320d603f354cbfdedb2f5f9f292 MD5 | raw file
Possible License(s): Apache-2.0, MIT
 1"use strict";
 2var myClass = {};
 3(function () {
 4  var msg = "Hello World!";
 5  myClass.say = function () {
 6    console.log(msg);
 7  };
 8  myClass.think = function (what) {
 9    msg = what;
10  };
11}());
12
13
14myClass.say();
15myClass.think("I love yellow.");
16msg = "Hello Again.";
17myClass.say();
18
19
20
21
22"use strict";
23var myClass = {};
24(function () {
25  var msg = "Hello World!";
26
27  myClass.say = function () {
28    setTimeout(function () {
29      console.log(msg);
30    }, 2000);
31  };
32
33  myClass.think = function (what) {
34    msg = what;
35  };
36}());
37
38myClass.say();
39myClass.think("B-A-N-A-N-A-S!");
40
41
42
43
44
45
46"use strict";
47var myClass = {};
48(function () {
49  var msg = "Hello World!";
50
51  myClass.say = function () {
52    var myMsg = msg;
53    setTimeout(function () {
54      console.log(myMsg);
55    }, 2000);
56  };
57
58  myClass.think = function (what) {
59    msg = what;
60  };
61}());
62
63setTimeout(function () {
64  myClass.think("Housetop");
65  myClass.say();
66}, 2000);
67
68myClass.say();
69myClass.think("B-A-N-A-N-A-S!");
70myClass.say();
71
72setTimeout(function () {
73  myClass.think("Treetop");
74  myClass.say();
75}, 1000);