You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Sprint-1/4-stretch-explore/objects.md
+17-40Lines changed: 17 additions & 40 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,26 +15,20 @@ Answer the following questions:
15
15
What does `console` store?
16
16
What does the syntax `console.log` or `console.assert` mean? In particular, what does the `.` mean?
17
17
18
-
Step 1: Type console.log and hit Enter
18
+
1. Answer (What does `console` store)?
19
19
20
-
What you’ll see in Chrome’s Console:
20
+
What is seen in Chrome’s Console is:
21
21
22
22
ƒ log() { [native code] }
23
23
24
-
Meaning:
25
-
This shows that console.log is a function, specifically one that’s built into the browser (that’s what “native code” means — it’s implemented in C++ within Chrome’s V8 engine, not in JavaScript itself).
24
+
This shows that console.log is a function, specifically a built-in function into the browser (that’s what “native code” means)
26
25
27
-
Step 2: Type just console and hit Enter
28
-
29
-
What you’ll see:
30
-
An object printed in the console — something like:
26
+
2. Answer Step 2 (What does the syntax `console.log` or `console.assert` mean? In particular, what does the `.` mean?)
This shows that console is a built-in JavaScript object.
30
+
This shows that console function is a built-in JavaScript object.
31
+
As it's expect because in Javascript, function is an object type.
38
32
39
33
It contains many methods (functions) such as:
40
34
@@ -46,51 +40,34 @@ warn() → prints warnings (in yellow)
46
40
47
41
assert(), table(), clear(), etc.
48
42
49
-
So you can think of console as a toolbox full of functions for logging and debugging.
43
+
We can think of console as a tool for for logging and debugging.
50
44
51
-
Step 3: Type typeof console
52
-
53
-
Output:
45
+
3. typeof console
54
46
55
47
"object"
56
48
57
-
Meaning:
58
49
This confirms that console is an object in JavaScript.
59
50
60
-
Now, answering the questions directly
61
-
What does console store?
62
-
63
-
console stores an object that provides access to a collection of built-in methods used for outputting information to the browser’s developer console.
51
+
Going back to the question asked "What does console store?"
64
52
65
-
It’s part of the Web API — the environment provided by browsers, not part of the JavaScript language itself.
53
+
It can be said console function stores an object that provides access to a collection of built-in methods and property used to displaying information to the browser’s developer console.
66
54
67
-
What does the syntax console.log or console.assert mean?
55
+
4.What does the syntax console.log or console.assert mean?
68
56
69
57
console.log means:
70
58
71
-
Access the property named "log" inside the object named console.
59
+
Access the property named "log" that is part of the object named console.
72
60
73
61
console.assert means:
74
62
75
63
Access the property named "assert" inside the same object.
76
64
77
-
In both cases, the property happens to store a function — so you can call it using parentheses, like console.log("Hi!").
78
-
79
-
What does the . (dot) mean?
80
-
81
-
The dot (.) is the property access operator in JavaScript.
82
-
83
-
It’s used to access a property or method belonging to an object.
84
-
85
-
In general:
86
-
87
-
object.property
65
+
5. What does the . (dot) mean?
88
66
89
-
means “get the value of property that belongs to object”.
67
+
The dot (.) is the method or property access operator in JavaScript.
90
68
91
-
Examples:
69
+
It’s used to access a property or method that belongs to a said object.
92
70
93
-
console.log // accesses the log function in the console object
94
-
Math.PI // accesses the value of PI in the Math object
95
-
document.body // accesses the body element of the web page
71
+
console.log // accesses the log property in the console object
72
+
Math.PI // accesses the value of PI (3,1415...) in the Math object
0 commit comments