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('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
1/*
2
3shortcuts:
4
5command K = clears the console
6command shift M = toggle device toolbar
7command shift C = select something on the page
8
9you can also log in a variable you may have coded:
10
11x;
12[value of x at that moment]
13
14if you're animating something:
15noLoop();
16[stops the animation]
17
18loop();
19[continues the animation]
20
21you can also code somewhat intricate text:
22
23for (var i = 0; i > 10; i++) {
24 console.log([variable or anything]);
25}
26
27some functions are also available to use:
28
29function mousePressed() {
30 console.log([anything]);
31}
32
33function keyPressed() {
34 noLoop(); [or anything else]
35}
36
37*/