Skip to content

Latest commit

 

History

History
102 lines (92 loc) · 1.61 KB

File metadata and controls

102 lines (92 loc) · 1.61 KB

Objects

In this activity, we'll explore some additional concepts that you'll encounter in more depth later on in the course.

Open the Chrome devtools Console, type in console.log and then hit enter

What output do you get? ƒ log() { [native code] }

this tells that function’s name is log, in this case - console.log

Now enter just console in the Console, what output do you get back? This prints the entire console object with all its methods, like log, warn, error, etc. console {debug: ƒ, error: ƒ, info: ƒ, log: ƒ, warn: ƒ, …} assert : ƒ assert() clear : ƒ clear() context : ƒ context() count : ƒ count() countReset : ƒ countReset() createTask : ƒ createTask() debug : ƒ debug() dir : ƒ dir() dirxml : ƒ dirxml() error : ƒ error() group : ƒ group() groupCollapsed : ƒ groupCollapsed() groupEnd : ƒ groupEnd() info : ƒ info() log : ƒ log() memory : MemoryInfo {totalJSHeapSize: 54442408, usedJSHeapSize: 52085668, jsHeapSizeLimit: 4294967296} profile : ƒ profile() profileEnd : ƒ profileEnd() table : ƒ table() time : ƒ time() timeEnd : ƒ timeEnd() timeLog : ƒ timeLog() timeStamp : ƒ timeStamp() trace : ƒ trace() warn : ƒ warn()

Try also entering typeof console This prints 'Object'. Answer the following questions:

What does console store? object What does the syntax console.log or console.assert mean? In particular, what does the . mean? console.log("Hello") calls the log method to print something to the console.

console.assert(condition, "Message") calls the assert method to check a condition, and only prints the message if the condition is false.