Skip to content

Commit 85de39e

Browse files
committed
Explain the meaning of console.log and various console property and method inside console object
1 parent 2128a93 commit 85de39e

File tree

1 file changed

+17
-40
lines changed

1 file changed

+17
-40
lines changed

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

Lines changed: 17 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,20 @@ Answer the following questions:
1515
What does `console` store?
1616
What does the syntax `console.log` or `console.assert` mean? In particular, what does the `.` mean?
1717

18-
Step 1: Type console.log and hit Enter
18+
1. Answer (What does `console` store)?
1919

20-
What you’ll see in Chrome’s Console:
20+
What is seen in Chrome’s Console is:
2121

2222
ƒ log() { [native code] }
2323

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)
2625

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?)
3127

3228
Console {memory: MemoryInfo, debug: ƒ, error: ƒ, info: ƒ, log: ƒ, warn: ƒ, ...}
3329

34-
35-
Meaning:
36-
37-
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.
3832

3933
It contains many methods (functions) such as:
4034

@@ -46,51 +40,34 @@ warn() → prints warnings (in yellow)
4640

4741
assert(), table(), clear(), etc.
4842

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.
5044

51-
Step 3: Type typeof console
52-
53-
Output:
45+
3. typeof console
5446

5547
"object"
5648

57-
Meaning:
5849
This confirms that console is an object in JavaScript.
5950

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?"
6452

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.
6654

67-
What does the syntax console.log or console.assert mean?
55+
4. What does the syntax console.log or console.assert mean?
6856

6957
console.log means:
7058

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.
7260

7361
console.assert means:
7462

7563
Access the property named "assert" inside the same object.
7664

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?
8866

89-
means “get the value of property that belongs to object”.
67+
The dot (.) is the method or property access operator in JavaScript.
9068

91-
Examples:
69+
It’s used to access a property or method that belongs to a said object.
9270

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
9673

0 commit comments

Comments
 (0)