jQuery console log

You can work with console with jQuery or with raw javascript. You can find console in Chrome or in Firefox with firebug.

Writing code of pressed keyboard button to console log:

jQuery(function($){
	$(window).keyup(function(event){
		console.log(event.keyCode);
		console.log(typeof event.keyCode); // returns the type of element (string, integer, etc.)
	});
});

Showing in console time, that was spent on the current operation:

jQuery(function($){
	var timeName = '100';
	console.time(timeName);
	for(var i=0; i<100; i++) {
		console.log(i);
	}
	console.timeEnd(timeName);
});

Leave a Comment