Console Log, Errors & Warnings - Javascript Notes #2



// COMPLETE TUTORIAL ON CONSOLE LOG

// Print a string on the console
console.log("Hello world");

// Printing a number
console.log(34);

// Using console as a calculator
console.log("45 + 3 =",45+3);
console.log("45 - 3 =",45-3);
console.log("45 * 3 =",45*3);
console.log("45 / 3 =",45/3);

// Printing a bollean
console.log(true);

// Printing an array
console.log([25,48,68,425,12,32]);

// Printing an object
console.log({
    name: "Usman",
    age: 22
}
);

console.table({
    name: "Usman",
    age: 22
}
);

// Printing a warning
console.warn("This is a warning");

// Printing an error manually on console
console.error('Uncaught ERROR.');


// Printing time for execution of a specific code
// Put following code at start of any code
console.time("Your code took: ");
// Also Put following code at start of any code to check time
console.timeEnd("Your code took: ");


// to Check weather a condition is true or false and return error on false
console.assert(444>189, "This is not possible");

// Clear the console
console.clear();

// COMMENTS

// This is an example of single line comment

/*
This is
an example
of multiline
comment
*/

Comments

Popular Posts