Hi techies let’s have a small brunch with JavaScript
1/
👋 JavaScript is the language of the web! If you're new to JS, this thread will help you understand the basics: variables, data types, loops, conditionals, and syntax!
Let's dive in! 🏊♂️
2/
📋 Variables allow you to store data in JavaScript! There are 3 ways to declare variables:
- var (old way)
- let (block-scoped)
- const (constant)
let name = "Alice";
const age = 25;
Use let or const for modern JS! 🛠️
3/
🔢 Data Types: JavaScript has different types of data. The most common types are:
- String: "Hello"
- Number: 42
- Boolean: true / false
- Array: ["apple", "banana"]
- Object: {name: "Alice", age: 25}
🤓 And is wonderful, is that everything in JS is dynamic!
4/
🔄 Loops: Loops let you repeat actions. The most common loop is the for loop:
for (let i = 0; i < 5; i++) {
console.log("Number: " + i);
}
This prints numbers 0 to 4! You can also use while and forEach loops for different use cases! 🔁
5/
❓ Conditionals: You can make decisions in your code using if statements:
let age = 18;
if (age >= 18) {
console.log("You're an adult!");
} else {
console.log("You're a minor!");
}
This checks conditions and runs code based on the result.
6/
🏗️ Basic Syntax: JavaScript is case-sensitive and follows a specific syntax:
- Statements end with ;
- Code blocks are wrapped in { }
- Comments use // or /* */
Remember to keep your code clean and readable! 🧼
7/
🧠 Recap: In this thread, we covered:
- Variables (let, const)
- Data Types (String, Number, Boolean, etc.)
- Loops (for, while)
- Conditionals (if, else)
- Basic Syntax
Master these, and you’ll be well on your way to coding in JavaScript! 💻🎉
8/
💡 Pro Tip: Practice makes perfect! Try writing small programs using these concepts to get comfortable.
Stay tuned for more tips as we dive deeper into JavaScript in future threads! 👨💻🔥
In next thread, we are going to get deeper in understanding JavaScript Variables & Why You Should Avoid Global Variables 🚨( really avoid them )
#JavaScript #Frontend #Coding #WebDev #100DaysOfCode