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