-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathsample080.html
More file actions
22 lines (16 loc) · 793 Bytes
/
sample080.html
File metadata and controls
22 lines (16 loc) · 793 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<!DOCTYPE html><html lang="en"><body><script>
// functions can be stored in variables (funcA), arrays (funcB), and objects (funcC)
var funcA = function () { }; // called like so: funcA()
var funcB = [function () { } ]; // called like so: funcB[0]()
var funcC = { method: function () { } }; // too.method() or funcC['method']()
// functions can be sent to, and sent back from, functions
var funcD = function (func) {
return func
};
var runFuncPassedToFuncD = funcD(function () { console.log('Hi'); });
runFuncPassedToFuncD();
// functions are objects, which means they can have properties
var funcE = function () { };
funcE.answer = 'yup'; // instance property
console.log(funcE.answer); // logs 'yup'
</script></body></html>