-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathsubfunction.html
More file actions
55 lines (40 loc) · 1.49 KB
/
subfunction.html
File metadata and controls
55 lines (40 loc) · 1.49 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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title> New Document </title>
<meta name="Generator" content="EditPlus">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
</head>
<body>
<div id="demo"></div>
<script>
//Functions are objects, but objects are not functions. Of course you can store functions as object properties but you can't make a plain object "callable". Or what do you actually want to achieve? What should be the advantage of your second approach? – Felix Kling Feb 5 '11 at 12:02
var test = function () {
console.log(test.data);
//return str;
};
test.str = "ab";
console.log(test.str);
test instanceof Object;
//Javascript type undefined, number, boolean, object, string, function
test.data = 'hello';
//test.set = function (data) {
// test.data = data;
//};
//test.set('Test');
//test();
//This outputs Test to my javascript console. Now I was wondering, if there was a way to do it using something like this?
//var test = {
// this: function () {
// console.log(test.data);
// },
// data: 'hello',
// set: function (data) {
// test.data = data;
// }
//};
</script>
</body>
</html>