Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save officialrajdeepsingh/3024259e3fc139a4957f16a41464b314 to your computer and use it in GitHub Desktop.
Save officialrajdeepsingh/3024259e3fc139a4957f16a41464b314 to your computer and use it in GitHub Desktop.
Hey, My Name Rajdeep Singh. In This Article, We Learn Javascript Web Console API. I hope you enjoy that and give me feedback about that. Read On Medium
// =========================
// Console Web API lIST
// =========================
// assert ,clear,count,debug, dir, dirxml,error,group,groupCollapsed,
// groupEnd ,info,log,markTimeline, profile ,profileEnd ,table,time,
// timeEnd, timeStamp,timeline, timelineEnd,trace, warm, memory
//======
// Compatibility
//========
// Comman Way
// if (window.console) {
// console.log(window.console ,"test pass");
// } else {
// // dont Compatibility code here
// }
// unComan Way
// but recommanded
// if (!window.console) {
// console= { log :function () {}};
// }
// console.log(!window.console, "rtr");
//======
// console.assert(expression, message)
//========
// console.assert("0ne" === "one", "false not working ");
// console.assert("0ne" === 1, " false not working ");
// console.assert(false, "this working");
// console.assert(true, "this is not working");
//============================
// console.clear()
//=====================================
// console.clear();
//===============================
// console.count();
//=========================
// console.count();
// console.count("test");
//===============================
// console.countReset();
//=========================
// console.countReset();
// console.countReset("test");
// console.countReset("test2");
//=======================================
// console.debug();
//=================================
// var oneValue = 123;
// console.log("Console.log ", oneValue);
// console.debug("Console.debug ", oneValue);
// console.warn("Console.warn ", oneValue);
// console.info("Console.info ", oneValue);
// console.error("Console.error ", oneValue);
// console.log(" my name is %s %s Exmple by formating log ", "rajdeep", "singh");
//=======================================
// console.dir(document.body);
//=================================
// console.dir( document.body, " console.dir");
// console.dir({name: "rajdeep", lastName: "singh", age: 23}, " console.dir");
//=======================================
// console.dirxml();
//=================================
// console.dirxml( document.body, " console.dirxml");
// console.dirxml(
// {
// name: "rajdeep",
// lastName: "singh",
// age: 23
// },
// " console.dirxml"
// );
//======
// console.group()
//========
// const domNode = document.body
// const testObject = {
// key: 'value'
// }
// console.group('DOM node')
// console.dir(domNode)
// console.dirxml(domNode)
// console.log(domNode)
// console.groupEnd('DOM node')
// console.group('(JSON) object')
// console.dir(testObject)
// console.dirxml(testObject)
// console.log(testObject)
// console.groupEnd('(JSON) object')
// console.group('start group');
// console.log('start test 1');
// console.warn('start test 2');
// console.error('start test 3');
// console.groupEnd('start group')
//======
// console.profile()
//========
// console.profile('testing start')
// console.log('testing start');
// console.profileEnd('testing start')
//======
// console.trace()
//========
// function traceTest(a, b) {
// console.trace("Start Trace");
// return a + b;
// }
// traceTest(23, 3);
//======
// console.time()
//========
// console.time("time start");
// alert("Click to continue");
// console.timeLog("time start");
// alert("click again");
// console.timeEnd("time start");
// console.time("time start");
// console.timeLog("time start");
// console.timeEnd("time start");
// function test4() {
// console.timeStamp('Hello world!');
// }
// test4()
//======
// console Formatting Exmple
//========
// for (var i = 0; i < 3; i++) {
// console.log("Hello, My name is %s. You've called log %d times.", "Rajdeep Singh", i + 1);
// console.warn("Hello, My name is %s. You've called warn %d times.", "Rajdeep Singh", i + 1);
// console.info("Hello, My name is %s. You've called info %d times.", "Rajdeep Singh", i + 1);
// console.error("Hello, My name is %s. You've called error %d times.", "Rajdeep Singh", i + 1);
// }
// console.log("Hello, My name is %s. You've called log %d. Floting value %f and javscript object %O", "Rajdeep Singh", 1, 6.7 ,{test:'testing', num:34});
// console.warn("Hello, My name is %s. You've called warn %d. Floting value %f and javscript object %O", "Rajdeep Singh", 1, 5.7, {test:'testing', num:34});
// console.info("Hello, My name is %s. You've called info %d. Floting value %f and javscript object %O", "Rajdeep Singh", 1, 6.75, {test:'testing', num:34});
// console.error("Hello, My name is %s. You've called error %d. Floting value %f and javscript object %O", "Rajdeep Singh", 1, 6.7455, {test:'testing', num:34});
// style in formatting
// console.log("Hello, My name is %s.", "Rajdeep Singh");
// console.log("%cHello, My name is %s do working .", "color:red", "Rajdeep Singh" );
// console.warn("%cHello, My name is %s . working", " color:green", "Rajdeep Singh");
// console.warn(" %c Hello, My name is %s do notwork .", "Rajdeep Singh", "color:green" );
// console.log("Hello, My name is %s. You've called log. %o", "Rajdeep Singh", document.body);
// console.warn("Hello, My name is %s. You've called log. %o", "Rajdeep Singh", document.body);
// console.error("Hello, My name is %s. You've called log. %o", "Rajdeep Singh", document.body);
// console.info("Hello, My name is %s. You've called log. %o", "Rajdeep Singh", document.body);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment