1console.log('this string will show on console') // this string will show on console
2
3const strVar1 = 'fizz';
4const strVar2 = 'buzz';
5
6console.log('strVar1 is: ' + strVar1 + ' and strVar2 is: ' + strVar2) // strVar1 is: fizz and strVar2 is: buzz
7console.log(420) // 420
1var str = "Howdy GeeksforGeeks"
2var geek = {
3 book: "harrypotter",
4 price: "2000"
5};
6var geek2 = [10, 20, 30];
7console.log(str);
8console.dir(str);
9console.dir(geek);
10console.log("geek (log) = ", geek);
11console.dir(geek2);
12console.log("geek2 (log) = ", geek2);
13
14// Prints only string as dir() takes
15// only one parameter.
16console.dir("geek2 (dir) = ", geek2);
1console.assert()
2//Log a message and stack trace to console if the first argument is false.
3
4console.clear()
5// Clear the console.
6
7console.count()
8// Log the number of times this line has been called with the given label.
9
10console.countReset()
11// Resets the value of the counter with the given label.
12
13console.debug()
14// Outputs a message to the console with the log level debug.
15
16console.dir()
17// Displays an interactive listing of the properties of a specified JavaScript object. This listing lets you use disclosure triangles to examine the contents of child objects.
18
19console.dirxml()
20// Displays an XML/HTML Element representation of the specified object if possible or the JavaScript Object view if it is not possible.
21
22console.error()
23// Outputs an error message. You may use string substitution and additional arguments with this method.
24
25console.exception() // Non-Standard
26// An alias for error().
27
28console.group()
29// Creates a new inline group, indenting all following output by another level. To move back out a level, call groupEnd().
30
31console.groupCollapsed()
32// Creates a new inline group, indenting all following output by another level. However, unlike group() this starts with the inline group collapsed requiring the use of a disclosure button to expand it. To move back out a level, call groupEnd().
33
34console.groupEnd()
35// Exits the current inline group.
36
37console.info()
38// Informative logging of information. You may use string substitution and additional arguments with this method.
39
40console.log()
41// For general output of logging information. You may use string substitution and additional arguments with this method.
42
43console.profile() // Non-Standard
44// Starts the browser's built-in profiler (for example, the Firefox performance tool). You can specify an optional name for the profile.
45
46console.profileEnd() // Non-Standard
47// Stops the profiler. You can see the resulting profile in the browser's performance tool (for example, the Firefox performance tool).
48
49console.table()
50// Displays tabular data as a table.
51
52console.time()
53// Starts a timer with a name specified as an input parameter. Up to 10,000 simultaneous timers can run on a given page.
54
55console.timeEnd()
56// Stops the specified timer and logs the elapsed time in milliseconds since it started.
57
58console.timeLog()
59// Logs the value of the specified timer to the console.
60
61console.timeStamp() // Non-Standard
62// Adds a marker to the browser's Timeline or Waterfall tool.
63
64console.trace()
65// Outputs a stack trace.
66
67console.warn()
1console.log("Kiwi");
2>> Kiwi
3console.log(3+3);
4>> 6
5var fruit = "kiwis";
6var mavariable = "J'aime les "+fruit;
7console.log(mavariable);
8>> J'aime les kiwis
1console.log('log-message'); // Outputs a normal information log to the console window
2console.warn('warn-message'); // Outputs warning in the console window
3console.error('error-message'); // Outputs error in the console window
4console.table('table-message'); // Outputs a table of all the object properties