My First Hands-on Experience

Now I feel really excited to write Javascript codes, formally. The tutorial first introduces to the very basic things about Javascript. One of the best thing about Javascript is the logging mechanism which can log any message you want.

console.log("My Message");

This is really helpful in the case where you want to log something when some condition is met or otherwise. This is really a powerful tool I found in Javascript. I can use it to know if there is any error anywhere and pinpoint it.

Unlike any traditional languages I learned before, Javascript has a bit weird (say, unique) way of representing values such as strings and numbers. It has six different types of data-type values such as number, string, boolean, object, function, and undefined. But to store them in a variable, it uses only one keyword i.e. var. This is a mark of a loosely-typed language. The value undefined is stored in any variable which has not been assigned any other data-type value.

var message = "Let's learn Javascript.";

Here, the message variable contains a string type of data.

Numbers are another important datatype which can be represented in various ways.

// (double forward slash) starts a comment
var num1 = -13;     // integer
var num2 = 78.843;  // fractional
var num3 = 0x59B0;  // hexadecimal
var num4 = 017;     // octal
var num5 = 2.995e8; // scientific
var num6 = 0b1010;  // binary

Javascript uses 64 bits to represent a number. One of the bits is a sign bit and some bits are used to represent after- decimal digits. So the accuracy of representing decimal numbers can’t be achieved but one can represent very large number i.e. The actual maximum whole number that can be stored is in the range of 9 quadrillion (15 zeros).

Strings can be concatenated by using the + operator. Some non-printable, special characters, and Unicode characters can also be represented in a string.

See: Unicode Character Table.

var string1 = 'I can beat "You".';
var string2 = "This is not 'me'.";
var string3 = string1 + " " + string2;
// I can beat "You". This is not 'me'.

var special = "I can beat \"You\"";
// using escape sequence to write "(quote) symbol

var special2 = "You\\Me";
// using escape sequence to write \(backslash) symbol

var special3 = "You and\n\tMe.";
// \n = newline character and \t = tab character
// You and
//     Me.

var special4 = "You are a \
good guy, Javascript."
// You are a good guy, Javascript.

var unicode = "\u00E6"; // æ

The boolean data-type has just two value i.e. true and false. Javascript can be used as a calculator or a logical program as it supports various arithmetic operators (+, -, *, /, %), logical operators (&&, ||)unary operators (++. –, -, typeof), conditional operator(?:) and relational operators (>, >=, <, <=, ==, !=, ===, !==).

console.log(null || "user"); // "user"
console.log(null && "user"); // null
console.log(typeof false);   // boolean
console.log(typeof 0.1);     // number
console.log(typeof "");      // string
console.log(false ? 1 : 2);  // 2
console.log("ba" > 'bZ');    // true

Note 1: Prefer strict equals (===, !==) over simple equal (==, !=) for better type checking before comparison.

Note 2: In most of the cases, null and undefined can be used alternatively. Used mainly to denote an absence of a meaningful value.

Weird Javascript

console.log(null == undefined);  // true
console.log(null === undefined); // false
console.log(null == 0);          // false
console.log("" == false);        // true
console.log("" === false);       // false
console.log(typeof undefined);   // undefined
console.log(typeof null);        // object

Using these basic Javascript features, I could now develop a mini calculator or a logical program that can test logic. The chapter also taught me some weird Javascript pitfalls to stay alert.

Till now, my journey has been smooth and easy. Hope it stays the same.
Thanks for keeping up with me.
Enjoy! 🙂


Things I Learned

  • console.log()
  • Javascript Syntax
  • Javascript value types
  • Javascript operators

Introduction to Javascript

Today, I learned about some history and anecdotes of some of the historical events related to JavaScript that changed popularity of the language and the language itself.

JavaScript is a programming language like any many other programming languages released till date, yet it secures the place at the apex owing to its popularity and ease of learning for beginners.

Netscape NavigatorMozilla

It was created by Brendan Eich as a project to add interactivity for web contents in Netscape Navigator browser. Brendan created the language in 7 days and released publicly in 1995. Soon language spread it’s wings and started to fly high out of Netscape. Although some part of the name of the language uses the name of another popular language called Java, yet it resembles no other characteristics with Java. It was simply a choice of naming the language to increase popularity of the language. This was then that the language was formally standardized and named ECMAScript because of the controversies arising due to naming convention of both the language.

After formation of the standard of the language, the language has gone through many rigorous revisions and additions, thus resulting in many version changes. As of today, the current version is ECMAScript 6.


Things I Learned

  • What is JavaScript?
  • History of JavaScript

Preparing to Learn Javascript

“It is good to have an end to journey toward; but it is the journey that matters, in the end.”
― Ernest Hemingway

Before anyone starts a journey, one must make sure the journey completes properly. So today, I’m going to make a list of things I must adhere to, for jolly completion of my JavaScript learning journey.

Ask the Experts

The first thing I did before starting my journey is to ask the experts. I found a nice article – The Best Way to Learn JavaScript by Andrew Burgess which lays down a fundamental way to learn JavaScript. Following the article to Assignment #3 and skipping the Assignment #2 in the article, I’m going to start learning Javascript from the freely available online e-book Eloquent JavaScript, 2nd Edition by Marijn Haverbeke.

I also signed up at Freenode IRC Network and joined the ##javascript channel to connect and live chat with JavaScript pros around the globe.

No learning is successful without a good reference. And for JavaScript, the best reference is from its creators – The Mozilla Development Network. And a user-friendly searchable version available at DevDocs.io. I made the JavaScript docs offline by using the Offline link so that I can search the docs quickly.

The Next Thing

My father taught me that the only way you can make good at anything is to practice, and then practice some more.
― Pete Rose

So now I had to look forward to a testing lab environment where I could run my JavaScript codes freely to my heart’s desire. JSBin is a free live editing and testing platform which supports syntax highlighting and smart code completion for JavaScript.

For a smooth journey, a good path planning is necessary. But more importantly, one needs a good time planning.

Pomodoro Technique

It is one of most popularly used Time-Management method developed by Francesco Cirillo in the late 1980s. The method uses a timer to break down work into tomatoe-timer intervals traditionally 20 minutes in length, separated by short breaks. These intervals are known as “pomodori” (Italian word pomodoro for “tomato”). The method is based on the idea that frequent breaks can improve mental agility. This could help me study and practice JavaScript language and the exercises or projects continuously with the short breaks of 6 minutes in between pomodori. I’ll also be using this technique for writing this blog.

I’m using a freely available Focus Booster app for Windows to help me manage my time using this technique.
Also read: The Pomodoro Technique


Now, Let’s Start Learning JavaScript.