How well can you write Javascript?

Javascript has a lot of features and best practices that many of us actually don't use. 

Only if you have enough experience, you can get 10 out of 10 in this small test.


Please remember, this is not a professional or academic standard test. Take this as a fun and improve your knowledge! 




Rules

There are 10 points discussed below. Check if you actually know or use these JS features. If you know about them, you get 1 point for each. If not, you get 0.

Please note that no specific order is maintained here.

Let's see who gets 10 out of 10!

πŸš€ THE TEST BEGINS!


1. Do you use back ticks for strings when you need to combine variables or to use multi-line text?

If you still use the ancient + operator for these, it's time to upgrade!

ES6 added this feature to use back ticks for strings. This helps to write multi-line texts as well as using variables inside -



Do you use this feature? 
  • Yes => 1
  • No => 0

2. Do you use const and let

Still using var everywhere? Or upgraded to const and let?

  • Yes => 1
  • No => 0

3. Do you use === comparison? 

You may know that == converts to matching types before comparison. 

For example, This will return true even if you compare 1 and "1". 

That's why, === is a better way to write conditional statements. 

  • Yes => 1
  • No => 0

4. Do you use Switch Statement when multiple conditions are needed to test?

We need to write if statements frequently. But, sometimes, we forget about switch case and still write 10 if statements to test a single parameter πŸ‘€

collected from codingtag.com

  • Yes => 1
  • No => 0

5. Do you know you can omit parenthesis while creating object without arguments?




Javascript simplifies grammar here. Did you know about it?

  • Yes => 1
  • No => 0

6. Arrow Functions or Ancient style? 

It has been a long time since ES6 introduced Arrow functions.

Although, they are not equivalent but using arrow functions for most of the declaration(except cases: this, called with new) will make your code cleaner.

I still notice many people to do it in the ES5 way.

What about you?

  • Yes => 1
  • No => 0

7. Do you use eval()

Ahh, eval may give you some advantages sometimes, but do you know it creates horrible security risk? At the same time, it decreases performance. 

  • Yes => 0
  • No => 1

8. Do you Comment your Code?


Feels unnecessary? Well dude, it saves lives sometimes 😏

For example, when you need to work on your 6 months old project and you understands nothing. Comments will help you there.

  • Yes => 1
  • No => 0

9. Do you use Ternary Operators? 

Ternary Operators help to keep your code neat and clean! 

Collected from: https://www.digitalocean.com/community/tutorials/javascript-ternary-operators

  • Yes => 1
  • No => 0

10. Do you know about all these String and Array Methods? 


Believe me, you should know about them. It happens that you write a custom function for something but JS has built in methods for that.


Image Credit: https://www.tutsmake.com/javascript-string-methods-widely-used/
Note: A reader pointed out that charCodeAt() is not as important as the other methods listed here. Although it's widely used, I still agree and would like to remove it. I am not editing the original image as it was collected.



Image Credit: https://dev.to/tutsmake/20-javascript-array-methods-2h9o

Did you know all of these? 

  • Yes => 1
  • No => 0


Result πŸ€“!



How did you do?

Did you get 10 out of 10?

πŸ‘‡Comment your result below and let's see who gets the highest point!


Thanks for reading! πŸ˜‡

Comments

  1. I sort of prefer Object literals to switch statements TBH

    ReplyDelete

Post a Comment