Ronaldo Vitto Lewerissa

Software engineering learning documentation.

JavaScript for Noobs: Intro

During this post, I would generally be discussing about the “noob” features of Javascript.

I’m not saying that I’m a proficient Javascript guru, or whatever, it’s just these topics I’m going to write, are just plain noob 🙁

Nonetheless, get to know the basic is an essential step to getting your Javascript mastery. You should know that Michael Jordan itself practice whole a lot more on the basic techniques (dribbling, passing, shooting), rather than focusing out on the crazy moves typical ballers would do.

Let’s get started.

Statements

Statements, like in other programming language, are just “statement“, though.

[suhighlight]It’s a single line (mostly) instruction for the computer, that would generally end up with the semicolon[/suhighlight], as follows:

var awesome = 2 * z;

The = and * are an operator, that said, just like the old-school mathematical operation. If you got no hell of an idea about this, well, you’re screwed. Anyway, an operator have precedence as it’s base rule of who gets operated first. You should definitely check that out, I’m just not into pointing that for this post, not to say that I’m lazy 😉

Number 2 is a literal. [suhighlight]Values that are not being stored in a variable are called as a literal[/suhighlight]. You don’t get to say that z is a literal too, what it does is simply telling the computer to get the value stored in variable z .

Most of the time, computer (compilers/interpreters), read from the left to right. So it’s just like how most people read, unless if you’re Arabic…

Expressions

Aha! I bet you would probably confuse this with statements 🙂

Needless to say, it’s quite a different world, you might say. That’s why I put this on a different section.

The awesome explanation I got from the internet is this:

[suquote]An expression is syntactic construction that has a value. Expressions are formed by combining variables, constants, and method returned values using operators.[/suquote]

Well, that’s a lot to say. I can’t figure out what a “syntactic construction” mean, but I got to tell you, expressions are a combination of variables, constants, and method that produce a value. That’s it!

Let’s try few things:

var coolStuff = awesome * 2;

Let me ask you, how many expression you find on the preceding statement?

To make it short, it’s four! Let’s break this down a bit:

  • awesome is a variable expression, it get’s value from the awesome variable.
  • 2 is a literal expression.
  • awesome * 2  is an arithmetic expression.
  • coolStuff = awesome * 2 is an assignment expression.

Operators

I did mention a few times about operator, and yes, I did said that if you’re not good at this, you probably skipped school bunch of time (just kidding).

Let me list down the most commonly used Javascript operator. But, rather than writing it out by myself, I would prefer a screenshot from a well-known open source JavaScript book, You Don’t Know JavaScript! You should DEFINITELY check that out.

operator in javascript

Comments

You know the most arguable thing in the world? EVERYTHING. It’s the nature of human kind that we love to comment, I can prove you by referring you to Youtube. That is why Javascript gave you this noble feature for you people to comment. But this time, you are not going to comment what other people did, but more onto what you’ve did.

On several occasions, you would probably code for 2 hours non-stop, and then decide to take a few minutes break. You said to yourself, “Well, a 10 minutes nap would be fine.” Thus, you went for the nap.

After awhile you woke up, squeezing those little eyes on the monitor, and realize, “What on Earth am I doing for the past 2 hours!?”

That’s right, you forgot everything.

That’s when the comment would come for the rescue. You should always, I mean, ALWAYS, comment on your code. Period.

What you think about this post? Make sure to subscribe, comment, and thumbs up! I appreciate at my very best of what you guys might think about. Definitely check out on my previous post about my recent stupidproject 🙂

Written by Ronaldo Vitto Lewerissa

Read more posts by this author.