Introduction
This article is regarding the console usage in developer tools which is present across all browsers nowadays. Using the console effectively helps us in tracing a defect or debugging any JavaScript that arises during or after development. Most of us use console.log() which will be very effective for tracing and debugging purposes.
There are various built-in Console functions that can be used as you can see in the below screenshot.
The first important function that can be used is an asset, a console which will print only if the following conditions have failed. If used in the Ajax function, it will be very effective to print if any error happens after the success method is called. In many instances we mistakenly use try and catch above an Ajax function as it will not catch any exception, that's why there is an error property for Ajax function and still, we use console log inside the Ajax error function.

- function toTestAsser(a,b){
- console.assert(a>b, "the conditions failed");
- }

Ajax code
Output
- $.ajax({
- type: 'GET',
- url: url, // url will have the service call url
- success: function(response) {
- console.assert(response !=null, "Response from the service is null : ServiceName ")
- var t = response;
- },
- error: function(data) {
- console.error("error on get token for authorization");
- }
- })



Viknaraj ManogararajahPosted Jul 19, 2018, 6:41 AM
Nice Article...........