๐กThe DOM isnโt part of JavaScript โ it's provided by the browser! JavaScript just gives us the tools to work with it. ๐คฏ
๐3
๐ JavaScript Strict Mode:
Did you know JavaScript has a "strict mode" that helps you write safer and more optimized code? ๐
What is 'use strict'?
Adding 'use strict'; at the top of your script or function enforces stricter parsing and error handling, preventing common mistakes.
Benefits of Strict Mode:
โ๏ธ Catches silent errors by turning them into throw errors
โ๏ธ Prevents accidental global variables
โ๏ธ Disallows duplicate parameter names
โ๏ธ Makes eval() and arguments safer
โ๏ธ Restricts deprecated features
How to Use It?
Simply add this at the beginning of your script or function:
๐ Pro Tip:
Always use strict mode for cleaner, more reliable JavaScript!
#JavaScript #WebDev #CodingTips programming
Code.io
Did you know JavaScript has a "strict mode" that helps you write safer and more optimized code? ๐
What is 'use strict'?
Adding 'use strict'; at the top of your script or function enforces stricter parsing and error handling, preventing common mistakes.
Benefits of Strict Mode:
โ๏ธ Catches silent errors by turning them into throw errors
โ๏ธ Prevents accidental global variables
โ๏ธ Disallows duplicate parameter names
โ๏ธ Makes eval() and arguments safer
โ๏ธ Restricts deprecated features
How to Use It?
Simply add this at the beginning of your script or function:
'use strict';
function testStrict() {
let x = 10;
console.log(x);
}
๐ Pro Tip:
Always use strict mode for cleaner, more reliable JavaScript!
#JavaScript #WebDev #CodingTips programming
Code.io
Hey future devs! ๐
Iโm planning a FREE 30-day JavaScript course for absolute beginners: 1 topic/day (Variables, DOM, Projects, etc.) Daily tasks + mini-projects Zero to hero in 30 days! Would you join? Vote below! ๐
Iโm planning a FREE 30-day JavaScript course for absolute beginners: 1 topic/day (Variables, DOM, Projects, etc.) Daily tasks + mini-projects Zero to hero in 30 days! Would you join? Vote below! ๐
Anonymous Poll
61%
โ
Yes! Iโm in.
16%
๐ค Maybe
23%
๐ซ Not now
๐ง Day 1: Setup and Intro to JavaScript
Setup: What we need?
1. Install Nodejs: We don't need it now but for later use to run js with out the browser.
Download here
To confirm if you installed node on your computer open cmd/powershell and type node -v and it show the current version of node
2. ๐ Browser: I recommend chrome
For now we use the browser console
after you install chrome
ctrl + shift +j to open the console on windows
Mac: Command + Option + J
Setup: What we need?
1. Install Nodejs: We don't need it now but for later use to run js with out the browser.
Download here
To confirm if you installed node on your computer open cmd/powershell and type node -v and it show the current version of node
2. ๐ Browser: I recommend chrome
For now we use the browser console
after you install chrome
ctrl + shift +j to open the console on windows
Mac: Command + Option + J
nodejs.org
Node.js โ Download Node.jsยฎ
Node.jsยฎ is a free, open-source, cross-platform JavaScript runtime environment that lets developers create servers, web apps, command line tools and scripts.
๐ What is JavaScript?
JavaScript is a programming language used to make websites interactive.
While HTML builds the structure and CSS styles it, JavaScript brings it to life.
๐ง What can JavaScript do?
JavaScript is a programming language used to make websites interactive.
While HTML builds the structure and CSS styles it, JavaScript brings it to life.
๐ง What can JavaScript do?
Show alerts and messages
Handle button clicks
Create games
Validate forms (like checking if a name was entered)
Change content on the page without reloading
๐งชExample:
alert("Hello, world!"); // Try this one on your console.
๐ธ JavaScript Execution
I
Browsers ๐ like Chrome interpret and run JavaScript instantly like we are doing right now.
I
nline โ inside HTML tags (not recommended for maintainability)
Internal โ inside <script> tags in the HTML file
External โ linked via .js files (best practice)
Browsers ๐ like Chrome interpret and run JavaScript instantly like we are doing right now.
๐ง JavaScript Data Types
In JavaScript, data types tell us what kind of data weโre working with. There are two main categories:
๐น 1. Primitive Types
2. Non-Primitive (Reference) Types
In JavaScript, data types tell us what kind of data weโre working with. There are two main categories:
๐น 1. Primitive Types
String โ Text
๐ "Hello"
Number โ Numbers
๐ 42, 3.14
Boolean โ True or false
๐ true, false
Undefined โ A variable that hasnโt been given a value yet
๐ let x;
Null โ Intentionally empty
๐ let y = null;
2. Non-Primitive (Reference) Types
Object โ A collection of key-value pairs
๐ { name: "John", age: 25 }
Array โ A list of values
๐ [1, 2, 3, 4]
Function โ Reusable blocks of code
๐ function greet() { console.log("Hi!") }
Comments
Comments are important in making your code more readable. There are two ways of commenting:
Single line commenting
Multiline commenting
Multiline commenting:
Comments are important in making your code more readable. There are two ways of commenting:
Single line commenting
Multiline commenting
// commenting the code itself with a single comment
// let firstName = 'Yared'; single line comment
// let lastName = 'M'; single line comment
Multiline commenting:
/*
let location = 'AddisAbaba';
let age = 200;
let isMarried = false;
This is a Multiple line comment
*/
๐ง JavaScript Variables
Variables are containers that store data in memory. where we keep different types of data (like numbers, text, etc.).
๐งช Declaring Variables
โ๏ธ Avoid using var โ it's outdated and can lead to bugs due to weird behavior (weโll talk about that later in scope).
Example:
let age = 25; // can be updated later
const PI = 3.14; // constant value, doesn't change
Variables are containers that store data in memory. where we keep different types of data (like numbers, text, etc.).
๐งช Declaring Variables
let โ when the value can change
const โ when the value wonโt change
โ๏ธ Avoid using var โ it's outdated and can lead to bugs due to weird behavior (weโll talk about that later in scope).
Example:
let age = 25; // can be updated later
const PI = 3.14; // constant value, doesn't change
โ Rules for Naming Variables
To create valid variable names, follow these rules:
No starting with numbers
โ 1name โ โ
โ name1 โ โ
Only letters, digits, $, and _ are allowed
โ my-name โ โ
โ my_name or myName โ โ
Use camelCase (recommended)
โ userName, totalAmount
No spaces
โ user name โ โ
โ userName โ โ
๐ฝ Looking for YouTube channels but donโt know which ones to follow?
We got you covered! ๐ฝ
๐ก Here's a curated list of YouTube channels we highly recommend for learners:
๐ Traversy Media
๐ Net Ninja
๐ Fireship
๐ Web Dev Simplified
๐ Anson The Developer
๐ Programming With Mosh
๐ Telusko
๐ Amigos Code
๐ Derek Banas
๐ Join our Telegram channel for more awesome resources and updates!
๐ Click here to join
We got you covered! ๐ฝ
๐ก Here's a curated list of YouTube channels we highly recommend for learners:
๐ Traversy Media
๐ Net Ninja
๐ Fireship
๐ Web Dev Simplified
๐ Anson The Developer
๐ Programming With Mosh
๐ Telusko
๐ Amigos Code
๐ Derek Banas
๐ Join our Telegram channel for more awesome resources and updates!
๐ Click here to join
๐2