Intro to JavaScript Terms

As a primer to more in depth JavaScript discussions, I figured an intro to some of the terminology that we’ll be using might be helpful.  As this will not be a complete “Intro to JavaScript” (far from it, in fact), I’ll provide links to resources that I’ve found helpful along the way.

Resources

There are several sites that I use frequently in learning to code.  Obviously, freeCodeCamp is the main one.  As I mentioned in my first post, I am currently working through the front end development certification at freeCodeCamp and highly recommend it.  While working through the freeCodeCamp curriculum I use w3schools, MDN and Stack Overflow extensively as references.  I also found that Tutorial Republic is an excellent resource for HTML, CSS and Bootstrap (which is a powerful front end framework that makes creating responsive web pages much easier).

There are also a couple books that I’ve used along the way.  The first is ‘Eloquent JavaScript‘, which is an excellent free resource (available in print also) for learning JavaScript.  It’s not exactly a book for beginners, but the online version provides examples and problems that you can work through right in the browser.  It’s the best JavaScript resource I’ve found yet…   I also picked up the Head First books ‘HTLM and CSS‘ and ‘HTML5 Programming‘.  They’re more on the beginner side, but are written well and I found them helpful in learning to interact with the DOM (which we will get into in future posts).

Intro to Terminology

Now, to cover some terms we’ll be using frequently.  In future posts, I will have to assume a basic understanding of these languages, otherwise each post will be the length of a book.  So I urge you, if you have any questions about the concepts listed below, please use the resources listed above to read more about them.

In JavaScript, groups of data are called values and these values have types.  There are 7 data types in JavaScript:

  • undefined
  • null
  • boolean
  • string
  • symbol
  • number
  • object

Any of these data types can be stored in a variable.  To declare a variable, use the keyword ‘var’, as such:

The above statement created a variable named ‘a’.  It also includes a comment…  Anything written on a line after // is a comment and will be ignored by the browser.  You can also assign values to the variable when you create it. The following statements create variables and assign values of the various data types.

JavaScript provides several data structures called objects and arrays.  I plan on covering objects and arrays in depth in decipheredCode so for now will only cover each at a very high level.

Objects allow us to group data of various types (including other objects) as name:value pairs called properties.  Objects are used extensively in JavaScript, in fact JSON (JavaScript Object Notation) files are the way most programs pass data among themselves over the web.

An array is a list of objects or values, called elements, stored inside brackets and separated by commas.  Array elements can be accessed using bracket notation and indexes (note: first element in an array is index [0]).  An example of accessing the first element of an array would be:

The arr declared above would now have the string ‘apple’ as it’s first element (index [0]).  Chapter 4  of ‘Eloquent JavaScript’ gives a great explanation in the use of objects and arrays.

Another term used extensively in JavaScript, and programming in general, is function.  A function is a self contained block of code that can act on it’s own to do something.  A function can take a set of parameters (optional) and contains a block of code to act on those parameters.  Here’s an example of a function.

This function, named addOne, has one parameter (num).  The code inside the function creates a new variable called newNum, then sets newNum equal to num + 1 and returns the value of newNum.  The way we would use this function (or invoke it) is

This example calls the addOne function and passes the number 5 as an argument.  This function call would return the value 6.

What is an argument?  An argument is the actual value that you pass into the function, as opposed to a parameter, which is the name listed in the function definition.  I’ll be using these terms interchangeably here at decipheredCode (whether right or wrong…), so you can think of both arguments and parameters as something that gets passed into a function.

Now…  This has been a long, rambling post that mentioned a bunch of things but didn’t really explain anything in detail. I feel, however, that it was necessary before I started digging any deeper..  Hopefully, this will be helpful to someone just starting out on their journey to learn to code.  The next posts here at decipheredCode will start to dig into real problems.  Meantime, I urge anyone that is interested to check out the links that I mentioned above and to start getting their hands dirty by writing some code!

-Jeremy

Learning to Program? We’ll help straighten out the code…

Learning to code, becoming a self-taught programmer, can be a daunting task when you are just beginning the process. The good news is there are tons of resources out there to help.

I started my learn to code journey earlier this year and have spent many hours sorting through all the resources out there to find the good ones. In some cases, however, even the good resources include jargon that might be confusing and difficult to understand for the beginner. I’ve created crookedCode in an attempt to break through that jargon and help others along their journey.

What makes me qualified to write about something I’m only in the process of learning? Great question… Rather than trying to justify what makes me qualified to cover these subjects, let me give the two reasons why I’ve created this blog:

The first reason, as I mentioned above, is that I’ve spent many hours trying to find good resources to help along the way. I hope that sharing what I’ve learned, and where to look for help, will enable others spend more time learning to code (and less time looking for how to learn).

The second reason, and this is a bit more selfish, is that going back and writing posts about challenges and projects that I’ve already completed will help solidify the concepts in my head. I find that the best way to truly understand a concept is to try to teach it to someone else. So that’s what I plan to do.

I’m currently working my way through freeCodeCamp. If you’re interested in learning to program, especially web development, I highly recommend checking them out. It’s a completely free program, with a very active and supportive community, and if you need another reason, they’re also doing some social good through their work with nonprofits.

We’ll start by working through examples of the freeCodeCamp curriculum (both algorithm challenges and development projects) and move on from there as we get more proficient. That said, we’ll be focusing on the logic behind the algorithms and we’ll be coding in Javascript, HTML and CSS.

I’ve learned quickly that there are usually multiple ways to solve coding problems. So, being new to this, I’m sure that I will not always provide the most efficient solution or most elegantly written code, so I welcome the feedback and suggestions. Please keep it positive though, there are plenty of other sites out there where you can berate others and get your aggressions out, please treat this as a positive learning environment.

-Jeremy