First day of Bootcamp - Javascript

First day of Bootcamp - Javascript
Photo by Growtika / Unsplash

My First Day at Coding Bootcamp: Diving into JavaScript

Today was my first day at coding bootcamp, and wow, what a whirlwind of information! We jumped straight into the world of JavaScript, and I can already tell it's going to be a fun and challenging journey. From variables to loops, I got a crash course on the fundamentals of programming in JavaScript. Here’s a recap of what I learned today.

Variables and Data Types

We started with the basics: variables. Variables are the building blocks of any program, allowing us to store and manipulate data. In JavaScript, you can declare variables using let, var, or const. Each has its own nuances, especially when it comes to scope (more on that later).

We also touched on data types. JavaScript has several data types, including:

  • Strings: Text values, like "Hello, world!"
  • Numbers: Can be integers or floats, like 5 or 3.14
  • Booleans: true or false, essential for logic
  • Null and Undefined: Represent "no value" or "uninitialized value"
  • Objects: More complex data structures that store key-value pairs

Learning about data types was pretty straightforward, but I can see how understanding them deeply is crucial for writing effective code.

Static vs. Dynamic Typing

This was an interesting concept. JavaScript is a dynamically typed language, meaning you don't need to explicitly declare the type of a variable. The type is inferred at runtime. In contrast, statically typed languages (like Java or C++) require you to define the type when declaring a variable. This flexibility in JavaScript can be convenient but also tricky when debugging.

Comments: Leaving Notes for Future You

I learned about the importance of comments. Comments in code are like sticky notes for future you (or other developers). They don’t affect how the code runs but provide clarity on what your code is doing. In JavaScript, you can use:

  • // for single-line comments
  • /* */ for multi-line comments

Operators and Equality

We covered operators, which allow us to perform actions on variables and values. These include arithmetic operators (+, -, *, /), comparison operators (==, ===, !=, !==), and logical operators (&&, ||, !). One thing I had to pay close attention to was the difference between == and ===. The triple equals (===) checks both value and type, while double equals (==) only checks the value.

Control Flow: If Statements, Loops, and More

Next up were control flow statements, which help us decide what the program should do based on certain conditions.

  • If statements: These allow us to execute code based on a condition.
  • Loops: We covered while loops, for loops, and learned about the beauty of automating repetitive tasks. I found for loops to be particularly intuitive for iterating over arrays.

We also learned about truthy and falsy values. In JavaScript, some values evaluate to true (truthy) or false (falsy) even if they aren't explicitly true or false. For example, 0, "", null, undefined, and NaN are falsy, while anything else is truthy.

The switch statement was introduced as an alternative to multiple if-else conditions, which can make the code cleaner when dealing with multiple conditions.

I found the ternary operator (condition ? expr1 : expr2) to be a concise way to write simple conditional logic. It’s compact, but I’ll have to use it more before it becomes second nature.

Functions: The Building Blocks of Reusability

We wrapped up with an introduction to functions, one of the most critical concepts in programming. Functions allow us to encapsulate code into reusable blocks. We learned how to declare functions and then invoke (or call) them. A function can also return a value, which is useful for sending data back to the part of the program that called it.

We also looked at arrow functions, which are a shorthand syntax for writing functions. I think I’ll need to practice this more to fully appreciate its benefits.

Another key concept was the difference between parameters and arguments. Parameters are placeholders in function definitions, while arguments are the actual values you pass to the function when calling it.

Scope and the Power of Let, Var, and Const

Finally, we touched on scope, which determines where variables are accessible in your code. JavaScript has function scope and block scope, and the way variables behave depends on whether you use var, let, or const.

  • var has function scope and can sometimes lead to bugs due to hoisting.
  • let and const have block scope, which makes them safer for use inside loops and conditional statements.

Final Thoughts

Today was intense but exciting. JavaScript is so versatile, and I can already see its potential. I know there’s a lot more to learn, but I’m looking forward to diving deeper, writing more code, and mastering the intricacies of programming.

Can’t wait for day two!