Opetus
Oppimispolku
C#-konsolisovellusten virheenkorjaus (C#:n käytön aloittaminen, osa 6) - Training
C#-konsolisovellusten virheenkorjaus (C#:n käytön aloittaminen, osa 6)
Tätä selainta ei enää tueta.
Päivitä Microsoft Edgeen, jotta voit hyödyntää uusimpia ominaisuuksia, suojauspäivityksiä ja teknistä tukea.
Use the console
object's methods to write messages to the Console from your JavaScript.
You can also enter these methods into the Console. For example, in the Console, to enter a console
method that takes a variable:
In the Sources tool, in the Debugger, set a breakpoint in your JavaScript code.
In the Debugger, step through your code.
When you are in a valid context so that the desired variable is in-scope, enter a method of the console
object into the Console tool. The result is displayed in the Console.
Writes an error to the Console when expression
evaluates to false
.
console.assert(expression, object)
Log level: Error
const x = 5;
const y = 3;
const reason = 'x is expected to be less than y';
console.assert(x < y, {x, y, reason});
Clears the Console.
If Preserve Log is turned on, the clear method is turned off.
console.clear()
Writes the number of times that the count method has been invoked at the same line and with the same label
. Use the countReset method to reset the count.
console.count([label])
Log level: Info
console.count();
console.count('coffee');
console.count();
console.count();
Resets a count.
console.countReset([label])
console.countReset();
console.countReset('coffee');
Identical to the log method, except different log level.
console.debug(object [, object, ...])
Log level: Verbose
console.debug('debug');
Prints a JSON representation of the specified object.
console.dir(object)
Log level: Info
console.dir(document.head);
Prints an XML representation of the descendants of node
.
console.dirxml(node)
Log level: Info
console.dirxml(document);
Prints the object
to the Console, formats it as an error, and includes a stack trace.
console.error(object [, object, ...])
Log level: Error
console.error("I'm sorry, Dave. I'm afraid I can't do that.");
Visually groups messages together until the groupEnd method is used. Use the groupCollapsed method to collapse the group when it initially logs to the Console.
console.group(label)
const label = 'Adolescent Irradiated Espionage Tortoises';
console.group(label);
console.info('Leo');
console.info('Mike');
console.info('Don');
console.info('Raph');
console.groupEnd(label);
Identical to the log method, except the group is initially collapsed when it logs to the Console.
console.groupCollapsed(label)
Stops visually grouping messages. See the group method.
console.groupEnd(label)
Identical to the log method.
console.info(object [, object, ...])
Log level: Info
console.info('info');
Prints a message to the Console.
console.log(object [, object, ...])
Log level: Info
console.log('log');
Logs an array of objects as a table.
console.table(array)
Log level: Info
console.table([
{
first: 'René',
last: 'Magritte',
},
{
first: 'Chaim',
last: 'Soutine',
birthday: '18930113',
},
{
first: 'Henri',
last: 'Matisse',
}
]);
Starts a new timer. Use the timeEnd method to stop the timer and print the elapsed time to the Console.
console.time([label])
console.time();
for (var i = 0; i < 100000; i++) {
let square = i ** 2;
}
console.timeEnd();
Stops a timer. For more information, see the time method.
console.timeEnd([label])
Log level: Info
Prints a stack trace to the Console.
console.trace()
Log level: Info
const first = () => { second(); };
const second = () => { third(); };
const third = () => { fourth(); };
const fourth = () => { console.trace(); };
first();
Prints a warning to the Console.
console.warn(object [, object, ...])
Log level: Warning
console.warn('warn');
console
object Reference - Has a summary overview of the methods, and has one page per method, with additional syntax details.debug()
and monitorEvents()
.Huomautus
Portions of this page are modifications based on work created and shared by Google and used according to terms described in the Creative Commons Attribution 4.0 International License. The original page is found here and is authored by Kayce Basques.
This work is licensed under a Creative Commons Attribution 4.0 International License.
Opetus
Oppimispolku
C#-konsolisovellusten virheenkorjaus (C#:n käytön aloittaminen, osa 6) - Training
C#-konsolisovellusten virheenkorjaus (C#:n käytön aloittaminen, osa 6)
Ohjeet
Monitor changes in JavaScript using Live Expressions - Microsoft Edge Developer documentation
Watch JavaScript expression values in real time with Live Expressions. If you find yourself typing the same JavaScript expressions into the Console tool repeatedly, try Live Expressions instead.
Console features reference - Microsoft Edge Developer documentation
A comprehensive reference for every feature and behavior of the Console UI in Microsoft Edge DevTools.
Console tool utility functions and selectors - Microsoft Edge Developer documentation
Convenience utility functions, commands, and DOM selectors that are available in the Console tool in Microsoft Edge DevTools, but not through JavaScript source files.