The short form – Javascript

It was 5:40 AM and I hit Ctr + S for the last time to ensure everything is being saved and alas! My the application is ready for testing but I was baffled, concerned about the codes; of course it wasn’t the fear of getting bugs from the application but the concern of having shorter ways to what I’ve written in the program.

Shorter syntax is something every programmer should always lookout for as long it’s going to get the task done. Why would someone have a Jquery function and still select element the long-javascript way.

    var redBg = document.getElementById('red-bg'); 

when you can always use the Jquery Id selector

var redBg = $('#red-bg');

This thought of having shorter and better way of handling things always awake in the curiousity in me to lookout for shorter means.

I remember a coding workshop we had back then in my school, the topic was CSS3 animation and I quite understand well the trainees probably haven’t get use to the shorthand

 animation : slider .6s linear;

but then, I caught a lady doing something.
She had lines of code which was to animate a div box from right to left and they were to do a similar one to animate another box from top to bottom, but I caught her trying to re-write the same lines of code she has written earlier on when she could easily highlight the needed part and hit Ctr + C and Ctr + V.

Image result for surprise gif

I know that wasn’t a bad case but why would there be a shorter way of getting things done and people go for the longer one.

One thing I lookout for when I see a shortand to doing something is to check the pros and cons, after which I can decide on which of the availables to go for.

This is a Series on Javascript Shortands and we’ll explore several javascript statement/functions and the alternate ways to each.

As we proceed, this article will be updated so as to ensure it contain links to all the articles in this series. 

I’m missing out something from the list? Please take your time to tell me. It’s a way of contributing to the society.

Leave a Reply

Your email address will not be published. Required fields are marked *