loader image

Few JavaScript Features That Almost Nobody Knows

Have you ever been amazed by a developer using some cool JavaScript feature you had never seen before? Well, this happens to me all the time. And since programming is all about constant learning, I’m sure you’ve felt the same way at some point in time.

Indeed JavaScript is evolving every year with the introduction of doing complex or tedious tasks in just a few lines of code, but some aspects of the language have been baked into it for years however, they are not much talked about.

Nonetheless, these features help you overcome some of the most common issues we encounter while using this language.

In this article, I’m going to share some JavaScript features that I have found that not many people know about. Let’s get started.

Object.freeze

  • It makes an object or array immutable

console.time and console.timeEnd

  • console.time starts a timer and console.timeEnd ends it. The timer created should have content in the middle of them, so these functions will check how much time it takes for the code in the middle to execute.

console.error && console.warn

  • When an error occurs you will notice a red-looking error log in the console, you can make your own error log with this function. When a warning appears you will notice a yellow-looking log in the console,
  • you can make your own warning log with this function.

console.assert

  • The console.assert() method writes an error message to the console if the assertion is false. If the assertion is true, nothing happens.

console.table

  • Prints an array or object in a tabular format

Styling Console Logs

in Keyword

  • The ‘in’ keyword checks whether a property exists in an array or object

delete Keyword

  • The delete keyword deletes a property from an array or object

Have any doubts, leave a comment. I shall make sure to clarify them.

By Darsh Adak

Leave a Comment

Your email address will not be published.