Day 1 Recap of 30DaysofJavaScript
July 31, 2022 • 5 min read
Finished Day 1! Let's recap!
First day of the 30 Days of JavaScript challenge. How did it go?
To understand the reason I am learning JavaScript, read this blog post right here.
So, how was it to start learning a new programming language like JavaScript?
Well, it actually was kind of refreshing. Much of it was going over data types that I have not thoroughly reviewed in years. Because of this, I was reminded of a lot of simple rules that had simply been lost in the back of my mind and resurfaced as I went through Day 1.
If you want to see me learn about JavaScript in real time, click the YouTube link below, where I streamed Day 1 and most of Day 2!
YouTube stream of Day 1!!!
Now, we can discuss things that I learned/relearned, and things I found interesting.
The Browser Console Shortcut
One thing I noted was how we were going to run our code, and I knew the browser console would be involved. However, this was the first time I learned of the shortcut: Ctl+Shift+I. Never in my 24 years of living did I know that there was a shortcut to open up to the browser console. But now that I have, this may have been the biggest mind-blow thus far in my 30 Day journey of JavaScript.
JavaScript Doesn’t Need Semicolons?
While I was learning how to write my first “Hello World” program, I realized that Asabeneh never used semicolons, and I did not understand why, as I had learned prior that semicolons were used to terminate code statements.
In further research since the stream, I have found that while yes, JavaScript does indeed work with semicolons, as it uses ASI, or Automatic Semicolon Insertion.
Basically, this means that the JavaScript parser, depending on what is written, will interpret the code you write as if there were semicolons, with a few different exceptions, which I will probably learn more in-depth down the road.
Console.log(“Hello World!”)
After installing Node.js (which I was told would be used for later) and opening the console, I learned of the multiple ways to print using the console, and how the console.log function would take in a single argument like:
console.log("Hello World!");
We can also take in multiple parameters separated by commas:
console.log("Hello" , "World" , "!");
How to Add JavaScript to a Web Page
Now came the first new thing JavaScript related thing I have learned, that JavaScript can be written on a web page in three different ways:
- Inline script
- Internal script
- External script
Inline scripts are when you add JavaScript inside an HTML tage, such as when you write:
<button onlick = "alert('Welcome!');">click</button>
Internal scripts are when you write out the <script> tag, and within the tag itself you write out JavaScript code, such as:
<script><!--JS code would go here--></script>
And finally, external scripts are when you link an external JavaScript file (.js) to a <script> tag in an HTML file.
<script src = "introduction.js"></script>
Introduction to Data Types in JavaScript
The next part of Day 1 went over five primitive data types in JavaScript: String, Number, Boolean, undefined, Null, and Symbol.
Numbers can be split into Integers (negative, zero, and positive) and Floats (decimals).
Strings are a group of one or more characters that are set between single quotes, double quotes, or backticks. Examples can be 'a' , "jovin" and `JavaScript`.
Booleans are a value that looks at a comparison and is either true or false.
Undefined is when there is no value assigned to a variable.
Null means the variable has an empty value.
To check the data type of a variable, you can use the typeof operator, like in this example:
console.log(typeof "Jovin");
When running the above code, the console would print out string.
Comments in JavaScript
Comments are very similar to what I have learned in other languages such as C and Java.
Single line comments can be written with //.
//You can write a single line comments like this
Multiline comments will be written between /* and */.
/*
You can write
multiline comments
like this
*/
Variables in JavaScript
Variables are the containers for data, which are stored in reserved memory locations. In JavaScript, you can use the keywords var, let, or const to declare a variable.
Use let for variables that can change, const for data that does not change at all, and (according to this challenge) do not use var, as it has lots of leaks.
JavaScript variable names have to follow certain rules:
- Should not begin with a number
- Cannot use special characters besides $ and _
- Follow the camelCase convention(something I did not learn about until I taught myself some Java last year)
- Should not have space between words
For example, writing a variable like firstName is a valid way to create a variable, but you could not write a variable like 1st-name.
To set declare a variable with a data type, use the let or const keyword before typing the variable’s name, type the equal sign(assignment operator), then the data value.
let variableName = dataValue
And this is the end of my recap of Day 1 of 30DaysofJavaScript. It was fun, and I feel I did learn better while streaming. Interacting with people in real time while learning how a new programming language was a different experience that I enjoyed thoroughly.
You can check out my GitHub repo, where I stored my code from the stream, which has code examples and comments/notes I made about what I was learning.
Day 2 should be coming out soon! If you want to know when it comes out, subscribe to the blog below! Share if you found my content interesting, and consider buying me some boba with the link down below.
Until next time, wherever, and whenever you are, have an amazing day! Signing off.
If you liked this and would like to support, click the link below to send me a boba!!! 🧋