Javascript: A Practical Introduction


Javascript is one of the most trending and highly paid language in the tech industry right now.In my early days of my career, I struggled with javascript and soon realized that knowledge of implementing a slider or a plugin is not enough and I have to improve my basics to play with javascript. This article nucleus is “Practical Introduction to Javascript“.

Let’s begin with the very basic.

Window vs Document
Window: In very simple words “every tab is a window”. For example, window.close works when we close the tab.
Document: Whatever user see inside the tab is a document. For example, document.ready works when the page is fully loaded.

Alert vs Console.log
One of the worst and irritating way of checking output and debugging is “alert”. Javascript has got “console.log” function which is used to output data in the console of the browser.It has following benefits:

  • doesn’t freeze web page, it is non-blocking
  • shows very large output easily
  • easy to understand and explore insight of javascript objects

Generally, first thought comes in a fresher mind after hearing validation is form validation but here I explain you about “Variable Validation“. A variable can store form value, a random string, an array, an object or any value. Consider a scenario where we have to validate a variable and confirm that it contains some string value then the process I prefer is follows:

  • check whether the variable value is undefined or not
  • check whether the variable value is null or not
  • check for string length

Below function will solve the above problem with ease.

Array vs Object

When i take interviews, 95% of freshers don’t know the difference between javascript arrays and objects and believe me these two are the most used data type in javascript while developing fronted of any application.
Arrays can be “single dimensional only” in javascript. Eg.


Adding values to array and object

Above I explained some of the practical tips of javascript which I thought every newbie must learn to grow and hope these will be helpful for every developer thinking of learning javascript. Got any question, ask me now.