-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy path18-objects.html
46 lines (32 loc) · 1.26 KB
/
18-objects.html
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Demo</title>
</head>
<body>
<script type="text/javascript">
// Let's talk about objects - turn this up to 11
/*
An object is any piece of data that has it's own properties and methods
properties are key/value pairs
If I am an object "Dale", I would have the following properties (or variables)
hair: brown;
height: 69";
age: old;
music: metal;
I could also have the following methods (or the thing that the object does)
'drive a car';
'take a bus';
'teach a class';
*/
// the var tuna is an object because it has properties
var dale = 'I am a Dale';
// use the [dot] separator to get the properties of an object using the `.write` method. WOW, mind blown.
document.write(dale.length);
// The document is an object in itself.
// `document` is the object, `.write();` is the method on the object
</script>
</body>
</html>