Oh, JavaScript

Amana
3 min readMar 8, 2021

While attending a full-time Software Engineering bootcamp, we started by learning Ruby. A wonderful language especially for beginners, in my opinion. We spent about three months learning all the wonderful things we could. From creating CLI (Command Line Interface) projects all the way to Ruby on Rails, which I still love working with.

However, after the Ruby on Rails project, we moved to JavaScript and I began to doubt my entire coding journey. It was hard. I felt so much security and structure with Ruby on Rails only to feel lost within JavaScript. Then we moved over to React and I felt a lot better. But I still found myself a little behind with even the basics of JavaScript. So after graduating the program, I used gift money from friends to invest in my own relearning of JavaScript.

Within the next few blogs of mine, I’d like to aide in my learning by going over some of the things that make JavaScript the most popular language on the web. It is a wonderful language once you start to really work with it more.

Let’s start by talking about Variables. Simply put, Variables are names or identifiers, that represent values. There are two steps in the variable process. Declaration and Assignment.

You can either declare a variable or declare a constant. The difference is that a variables value can be changed, whereas, a constants value cannot. Variables are declared with either var or let keywords. Constants use the keyword const and must be assigned a value upon declaration. It is important to know that JavaScript only introduced the let and const keywords in ES6. var was the only way to declare variables before that.

Example:

As you can see from the code above, we are able to declare variables under var and let keywords without assigning them a value. We assign a value later and are also able to change that value when we want. With the const keyword, we must declare and assign our value in the same step.Variables are assigned, using the assignment operator, = , an equal sign.

What data type can be a value for our variables and constants?

JavaScript has several types of values that can be used.

Numbers

Strings: Any text within quotation marks or single quotes

Booleans: true or false

Objects: Name and value pairs that are within curly braces like; {}

Arrays: Lists that use numerical indices and are within square brackets like; []

Null: Special value that simply means “no value”

Undefined: Same as null

Knowing this, you’ll see plenty of variables that use objects and/or arrays as values. Something like;

let yourBio = {

firstName: “Tyler”,

lastName: “The Creator”,

age: 30,

profession: “Musician”

};

Photo by israel palacio on Unsplash

A very consistent naming convention for variables and constants in JavaScript is to maintain camelCase structure. So, a firstName variable will be different from a firstname or FirstName variable. Case matters!

Once your variable or constant has been declared and assigned a value you will soon find how time saving it is to write the rest of your code. Instead of always typing out your biography values, you can now simply refer to your yourBio variable. Saving time and space within your code.

--

--