Let’s get started.
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…
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.
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).
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 🙂