Beginner Fundamentals

Gedler Jean Pierre
5 min readApr 20, 2021

Journal Entry:

Just like perfecting any other skill, you must learn the fundamentals to perfect the craft. Javascript is like a puzzle you have to put together except there are multiple ways to solve the puzzle than just one. Sounds like a nightmare, doesn’t it? It has been nearly a month into my journey of learning this language and it has been fun! Sure, the syntax errors and nonstop researching have been a pain. But the “AHA” moments and finally figuring out the solutions to your code is like a reward you never stop being happy about. It’s like you learn so much and can understand code by looking at it but when you try to execute it yourself you catch yourself in a brain jam. If you’re feeling like this then just know you are not alone. I am a man that doesn’t know all things but what I do know is it’s better to understand why something isn’t working rather than wondering why something isn’t working. Yes, you read that right. Learning javascript can leave you confused on how to put everything together but with great understanding, we can at least put our foot on the gas rather than staying in park. We don’t want to stay in park. So without further ado, let’s talk about key topics in Javascript so we can start getting familiar with things. If we don’t know what to do at least we know how to start. We’re the ones that drive the car!

Variables

Variables are what we use to store information. Think of it as a gym locker, you store all your tools into that locker and only come back to it when you want to perform your gym duties. Like so, we refer back to a variable to process the information we stored. I think it’s best to understand that there are two different types of variables, Global Declarations & Scope. Let’s take a look at each of them.

Global Declarations

Global Declarations variables are easily accessible which makes them pretty flexible with how you can utilize them. In order to create a variable, you must first declare it. You can do this by using three keywords: let, const, and var. In case you’re wondering; keywords are built-in words in javascript that serve a function. When javascript notices these keywords, it performs whatever it was meant to do. In this case, the functions of let, const, and var allow you to declare a variable.

Scope

Scope variables aren’t as accessible as Global Declarations variables. The reason why is due to scope variables only existing within a certain block of code. If that block isn’t executed then the variable is practically invisible to what you’re running. You could imagine this being useful if you don’t want to make a variable present globally due to you only needing it after a specific event. Scope variables are great if we want to process information only after a specific event happened in our code.

Data Types & Structures

Variables have a value that will always be equal to one of the 6 primitive tyes. Primitive being basic values, nothing complex. The primitive types are undefined, boolean, number, string, symbol, and BigInt.

Variables can also have values that are data structures. These structures are non-primitive because they’re complex. Data structures examples: Array, Objects, and Functions

  • Arrays are used to make a list that is ordered. arrays can contain objects.
  • Objects are used to make a collection that isn’t ordered. Example: name, phone, and address.
  • Functions execute code inside their block whereas Arrays & Objects return values saved in their block. Functions take an input & return an output. Functions have to run a set of statements to calculate a value.
  • Note: Objects & Functions aren’t data types but they can store data tyes so it still falls in this category.

Type Conversions

This is the ability to change the data type from one to another. The two known types are explicit & implicit. An example of explicit would be changing a string to a boolean. Likewise, implicit would be automatic conversions javascript does for you

Loops

This is the ability to execute a line of code over & over until it reaches a condition that causes it to stop executing. A good example of this would be FOR LOOPS. We haven’t touched on the idea of functions but a callback function can be an effective way of doing loops depending on the circumstance.

Control Flow

Control Flow are conditions based on an input. A good example of this would be If, Else, and Else If statements. This has multiple blocks of code ready to run if the input returns to one of them. If nothing comes true to any of the conditions, it’ll run whatever block of code is in the Else block.

Switch statements are another example and can be extremely useful when you have multiple conditions

Operator

We talked about variables and how they can have a value that is primitive or non-primitive(arrays, objects, and functions). However, before you assign a value you must assign an operator. Below are the most common types of operators used in javascript.

arithmetic: math operators

++ = increments & returns value → x= 3++ → returns 4.

— — = increments going down

% = this is called Modulus. It returns the value of the remainder in division → 10 % 5 → returns 0

logical: compares two sets of data to determine if true or false

&& = returns true if both sets of data have the same value. Example: 3 >2 && 5>3 → returns false; must be same value

|| = returns true even if one of the sets of data is true. Examples:

3 > 1 || 2 > 5 → returns true; at least one set of the data was true.

! = returns true if data is false → 3 ! =2 returns true cause its false

String = combines two strings together using + . Examples: “A” + “BC” → returns ABC.

Note: Operators can be used anywhere, not just variables.

Conclusion

Javascript can be exciting but overwhelming when starting off. It’s okay if you aren’t memorizing all the concepts and cracking the puzzle as fast as you’ll like. I’m currently a month in and I still find myself not performing at the pace that I would love. But you know what? That’s okay because concepts are beginning to stick the more and more I write code. You can’t spell impossible without possible. Which means… it is very possible you can do the same. Enjoy the errors and get comfortable at your own pace because it will all be worthwhile. Until next time, keep coding.

--

--