-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnested_functions.js
More file actions
51 lines (37 loc) · 908 Bytes
/
nested_functions.js
File metadata and controls
51 lines (37 loc) · 908 Bytes
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
// constructor style
function root() {
console.log("Executing root");
this.toString = function () {
return "I'm a root";
}
this.name = "root object";
}
//returns an object
function root2() {
console.log("Executing root2");
console.log(this.constructor.name);
var obj = {
toString: function () {
return "I'm a root";
},
name: "root object"
}
obj.name += " 3";
return obj;
}
var myRoot = new root();
var myR = root();
var myRoot2 = root2();
var myRoot3 = new root2();
console.log(myRoot.toString());
console.log(myRoot.name);
console.log(myRoot2.toString());
console.log(myRoot2.name);
console.log(myRoot3.toString());
console.log(myRoot3.name);
// console.log(myR.toString());
// console.log(myR.name);
var myNumber = Number();
var mySecond = new Number();
console.log(myNumber);
console.log(mySecond);