Console stability: 4-APIforzen can print to stdout and stderr ). like the consoles provided by most web browsers, the console output in node is sent to the standard output stream and standard error stream. console. log ([...
Console)
Stability: 4-API forzen
It can print to stdout and stderr ). like the consoles provided by most web browsers, the console output in node is sent to the standard output stream and standard error stream.
Console. log ([data], [...])
In the standard output stream, a new row is printed. This method can support multiple parameters like printf (), for example, [javascript] view plaincopyprint?
Console. log ('count: % d', count );
Console. log ('count: % d', count );
If the formatted element is not found in the first string, node uses util. inspect to check each parameter. For more information, see util. format ()
Console.info ([data], [...])
Equivalent to the console. log () method.
Console. error ([data], [...])
Equivalent to the console. log () method. It is only printed to the standard error stream.
Console. warn ([data], [...])
Equivalent to the console. error () method.
Console. dir (obj)
Use uitl. inspect to check obj and print the result string to the standard output stream.
Console. time (label)
Mark a time point and start timing from this time point.
Console. timeEnd (label)
End the timer. Use the timer set by lable to print the console. time (label) to console. timeEnd (label) is the number of milliseconds used. For example, (in this example, if the value is 0 ms, I changed it to 5 SM after cycles): [javascript] view plaincopyprint?
Console. time ('2014-elements ');
For (var I = 0; I <100; I ++ ){
;
}
Console. timeEnd ('2014-elements ');
Console. time ('2014-elements ');
For (var I = 0; I <100; I ++ ){
;
}
Console. timeEnd ('2014-elements '); console. trace (label)
Print the stack tracing information at the current position to the standard error stream.
Console. assert (expression, [message])
Like the assert. OK () function, if the expression parameter is verified as false, an AssertionError error is thrown. The error message is the message parameter.
Timer (Timer)
Stability: 5-locked
All timer functions are global objects. You do not need to call the require () method to require them.
SetTimeout (callback, delay, [arg], [...])
Execution: Execute callback once after delay milliseconds. A timeoutId is returned for use in the clearTimeout () method. You can pass parameters to the callback function as needed.
It should be noted that your callback function may not be called exactly after delay milliseconds, and node cannot ensure that callback is triggered or required within a precise time.
The callback function will be triggered as close as possible to the specified time.
ClearTimeout (timeoutId)
Prevents a timeout event represented by timeoutId from being triggered.
SetInterval (callback, delay, [arg], [...])
Custom repeated execution-call back every time after delay milliseconds. An intervalId is returned to facilitate use in the clearInterval () method. You can pass parameters to the callback function as needed.
ClearInterval (intervalId)
Prevents an interval event represented by an intervalId from being triggered.