Training
Percorso di apprendimento
Eseguire il debug di applicazioni console C# (Introduzione a C#, Parte 6) - Training
Eseguire il debug di applicazioni console C# (Introduzione a C#, Parte 6)
Questo browser non è più supportato.
Esegui l'aggiornamento a Microsoft Edge per sfruttare le funzionalità più recenti, gli aggiornamenti della sicurezza e il supporto tecnico.
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()
.Nota
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.
Training
Percorso di apprendimento
Eseguire il debug di applicazioni console C# (Introduzione a C#, Parte 6) - Training
Eseguire il debug di applicazioni console C# (Introduzione a C#, Parte 6)