Say no to console.log!

Do you always use console.log in your projects during development?

And even though we will keep using console.log, there are other alternatives that will make your development more fun and productive.

console.dir()

For hierarchical listing…


This content originally appeared on DEV Community and was authored by Alish Giri

Do you always use console.log in your projects during development?

And even though we will keep using console.log, there are other alternatives that will make your development more fun and productive.

console.dir()

For hierarchical listing of arrays and objects.

console.dir(["apples", "oranges", "bananas"]);

console.dir example

console.table()

For rows and columns listing of objects and arrays.

console.table(["apples", "oranges", "bananas"]);

console.table array example

console.table({"a": 1, "b": 2, "c": 3});

console.table object example

console.group()

console.log("This is the top outer level");

console.group("Task 1");
console.log("Task activity 1");
console.log("Task activity 2");
console.groupEnd();

console.log("Back to the top outer level");

console.time() & console.timeEnd()

try {
  console.time("recording...");
  await someAsyncTask();
} catch (error) {
   // handle error
} finally {
  console.timeEnd("completed");
}

console.clear()

This will clear the console.

I hope this was helpful! 🚀


This content originally appeared on DEV Community and was authored by Alish Giri


Print Share Comment Cite Upload Translate Updates
APA

Alish Giri | Sciencx (2024-06-17T18:34:53+00:00) Say no to console.log!. Retrieved from https://www.scien.cx/2024/06/17/say-no-to-console-log/

MLA
" » Say no to console.log!." Alish Giri | Sciencx - Monday June 17, 2024, https://www.scien.cx/2024/06/17/say-no-to-console-log/
HARVARD
Alish Giri | Sciencx Monday June 17, 2024 » Say no to console.log!., viewed ,<https://www.scien.cx/2024/06/17/say-no-to-console-log/>
VANCOUVER
Alish Giri | Sciencx - » Say no to console.log!. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/06/17/say-no-to-console-log/
CHICAGO
" » Say no to console.log!." Alish Giri | Sciencx - Accessed . https://www.scien.cx/2024/06/17/say-no-to-console-log/
IEEE
" » Say no to console.log!." Alish Giri | Sciencx [Online]. Available: https://www.scien.cx/2024/06/17/say-no-to-console-log/. [Accessed: ]
rf:citation
» Say no to console.log! | Alish Giri | Sciencx | https://www.scien.cx/2024/06/17/say-no-to-console-log/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.