Skip to content

Commit 269ce23

Browse files
committed
Console.log and Console and property
1 parent 94b7128 commit 269ce23

File tree

1 file changed

+80
-0
lines changed

1 file changed

+80
-0
lines changed

Sprint-1/4-stretch-explore/objects.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,83 @@ Answer the following questions:
1414

1515
What does `console` store?
1616
What does the syntax `console.log` or `console.assert` mean? In particular, what does the `.` mean?
17+
18+
Step 1: Type console.log and hit Enter
19+
20+
What you’ll see in Chrome’s Console:
21+
22+
ƒ log() { [native code] }
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).
26+
27+
Step 2: Type just console and hit Enter
28+
29+
What you’ll see:
30+
An object printed in the console — something like:
31+
32+
Console {memory: MemoryInfo, debug: ƒ, error: ƒ, info: ƒ, log: ƒ, warn: ƒ, ...}
33+
34+
35+
Meaning:
36+
37+
This shows that console is a built-in JavaScript object.
38+
39+
It contains many methods (functions) such as:
40+
41+
log() → prints messages
42+
43+
error() → prints error messages (in red)
44+
45+
warn() → prints warnings (in yellow)
46+
47+
assert(), table(), clear(), etc.
48+
49+
So you can think of console as a toolbox full of functions for logging and debugging.
50+
51+
Step 3: Type typeof console
52+
53+
Output:
54+
55+
"object"
56+
57+
Meaning:
58+
This confirms that console is an object in JavaScript.
59+
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.
64+
65+
It’s part of the Web API — the environment provided by browsers, not part of the JavaScript language itself.
66+
67+
What does the syntax console.log or console.assert mean?
68+
69+
console.log means:
70+
71+
Access the property named "log" inside the object named console.
72+
73+
console.assert means:
74+
75+
Access the property named "assert" inside the same object.
76+
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
88+
89+
means “get the value of property that belongs to object”.
90+
91+
Examples:
92+
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
96+

0 commit comments

Comments
 (0)