console.log([data], [...])
console.info([data], [...])
console.error([data], [...])
console.warn([data], [...])
console.dir(obj)
console.time(label)
console.timeEnd(label)
console.trace(label)
console.assert(expression, [message])
Usage of console.log([data], [...]),console.info([data], [...]),console.error([data], [...]),console.warn([data], [...])
Print the output in a newline .
This function can take multiple arguments like a printf() in C or System.out.println() in Java
Example Consloe.js:
Out Put:
D:\nodejs>node Console.js
This is console log output
This is output of,console log
Usage of console.dir(obj):
{ name: 'Kotini', LastName: 'Srinu' } ]
D:\nodejs>
Usage of console.time(label) and console.timeEnd(label)
console.time(label):
Mark or start record a time.
console.timeEnd(label):
Finish timer, record output.
Example ConsloeTime.js:
Out Put:
D:\nodejs>node ConsloeTime.js
Itr 0
Itr 1
Itr 2
Itr 3
Itr 4
Itr 5
Itr 6
Itr 7
Itr 8
Itr 9
10-elements: 2ms
D:\nodejs>
Usage of console.trace(label)
Print a stack trace as a stderr at the current position.And break the execution.
Its kind of throwing exception.
Example ConsloeTrace.js:
console.info([data], [...])
console.error([data], [...])
console.warn([data], [...])
console.dir(obj)
console.time(label)
console.timeEnd(label)
console.trace(label)
console.assert(expression, [message])
Usage of console.log([data], [...]),console.info([data], [...]),console.error([data], [...]),console.warn([data], [...])
Print the output in a newline .
This function can take multiple arguments like a printf() in C or System.out.println() in Java
Example Consloe.js:
var data=[{"name":"Kotini","LastName":"Tirumula"},{"name":"Kotini","LastName":"Srinu"}];
console.dir(data);
Out Put:
D:\nodejs>node Console.js
This is console log output
This is output of,console log
Usage of console.dir(obj):
Example ConsloeDir.js:
var data=[{"name":"Kotini","LastName":"Tirumula"},{"name":"Kotini","LastName":"Srinu"}]; console.dir(data);
Out Put:
D:\nodejs>node ConsoleDir.js
[ { name: 'Kotini', LastName: 'Tirumula' },{ name: 'Kotini', LastName: 'Srinu' } ]
D:\nodejs>
Usage of console.time(label) and console.timeEnd(label)
console.time(label):
Mark or start record a time.
console.timeEnd(label):
Finish timer, record output.
Example ConsloeTime.js:
console.time('10-elements');
for (var i = 0; i< 10; i++)
{
console.log("Itr "+i);
}
console.timeEnd('10-elements');
Out Put:
D:\nodejs>node ConsloeTime.js
Itr 0
Itr 1
Itr 2
Itr 3
Itr 4
Itr 5
Itr 6
Itr 7
Itr 8
Itr 9
10-elements: 2ms
D:\nodejs>
Usage of console.trace(label)
Print a stack trace as a stderr at the current position.And break the execution.
Its kind of throwing exception.
Example ConsloeTrace.js:
console.log('1st Line');
console.log('2nd Line');
console.trace('trace Here');
console.log('4th st Line');
Out Put:
D:\nodejs>node ConsloeTrace.js
1st Line
2nd Line
1st Line
2nd Line
D:\nodejs\ConsloeTrace.js:3
console.tace('trace Here'); ^
console.tace('trace Here'); ^
TypeError: Object # has no method 'tace'
at Object. (D:\nodejs\ConsloeTrace.js:3:9)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:901:3
D:\nodejs>




