Tuesday 26 April 2016

The Complete Node JS Developer Course - Variables, Error Messages & Strings

Variables


Lesson 8 is an introduction to variables.

A great thing about this course, and something that would have been extremely useful when I was doing the codecademy JavaScript course, is the brief introduction to error messages. This is vital knowledge for people who want to work in the field of programming.

Jumping ahead slightly, here's a quick insight from lesson 9:

It's common to see variable names that start with a lower case letter. A useful thing to know is that the first character in the name of a variable can also be an upper case letter, an underscore _ or a dollar sign $. The subsequent letters of a variable can be lower or upper case letters, or numbers, i.e. from 0 to 9.

Error Messages


Andrew shows you the right way to create a simple variable, using the var key word, and he explains that var is used to signify a variable, but it cannot be used to name a variable. In order to explain that concept, he gets us to deliberately create a variable with the name var so we can see the error message that it throws up.

This course is getting a big thumbs up from me so far! :)

Strings


In lesson 9 we learn how to identify and create a string.


Usually programmers use a single quotation for strings, because it doesn't require any thinking. You just tap the key on the keyboard and voila! But you could use double quotes if you wanted, but that would require pressing the shift key as well, so it's more to think about.

It's best practice to use the same type of quotation marks consistently throughout your code, so programmers tend to choose the single quotes as it's the most instinctive option.

This is another helpful insight from Andrew as he really gets into the psyche of the newbie.

No comments:

Post a Comment