Orbit Reached
You have completed all mission contexts.
Ready for Liftoff
You now know how to talk to the browser, create storage boxes, and read errors. Your spaceship is fueled. Next, we look at what exactly we can put inside those boxes.
Code Execution: Parsing
Before running anything, the computer quickly scans your whole file to learn where the variables and functions are. This is called parsing.
Strict Mode
Typing 'use strict' at the top of your code turns the computer into a strict teacher. It stops you from making lazy mistakes and forces clean coding habits.
The Window Object
In a browser, the 'Window' is the master container. It represents the actual browser tab you are looking at, and it holds all your code.
JS is not Java
JavaScript and Java have almost nothing in common. Calling them the same is like saying 'Car' and 'Carpet' are the same because they share letters.
History of JS
JavaScript was created in just 10 days in 1995. It was originally built just to make web forms slightly animated, and now it runs everything from websites to rockets.
Debugging
Debugging is the art of being a detective in a crime movie where you are also the murderer. You read the red errors to trace exactly where your code broke.
Reference Errors
This happens when you ask the computer for a box (variable) that doesn't exist yet. You asked for 'fuel', but you never actually created the 'fuel' box.
Syntax Errors
A syntax error means you broke the grammar rules. You forgot a parenthesis, misspelled a word, or missed a quote mark. It's a typo.
What is an Error?
When the computer doesn't understand your command, it throws a red error in the console. Don't panic! It's just the computer saying, 'I need you to clarify this.'
External vs Internal JS
You can write JS directly inside the HTML file, but it's cleaner to put it in its own separate file (like app.js) and link it. It keeps your workspace organized.
The HTML Script Tag
To link your JavaScript to a website, you put a '<script>' tag in your HTML file. Itās the bridge connecting your code to the visual webpage.
Executing Code Top to Bottom
The computer reads your code exactly like a book: line 1, then line 2, then line 3. It won't skip ahead unless you explicitly tell it to.
Interacting: prompt()
To ask the user a question, use 'prompt('What is your name?')'. It gives them a pop-up with a text box to type their answer.
Interacting: alert()
Want to annoy a user? Use 'alert('Warning!')'. It creates a pop-up box on the screen that forces the user to click OK before doing anything else.
Case Sensitivity
JavaScript is extremely strict about capitals. 'apple', 'Apple', and 'APPLE' are treated as three completely different things.
Multi-line Comments
If you have a really long note, you wrap it in '/*' and '*/'. Everything between those symbols is ignored by the machine.
Leaving Comments
Sometimes you want to leave notes for humans that the computer ignores. Putting '//' before text makes it a comment. The computer skips it completely.
The Semicolon ;
A semicolon in JavaScript is like a period at the end of an English sentence. It tells the computer, 'I am done giving this specific instruction.'
Statements vs Expressions
A statement is a full sentence or action (like 'Stand up'). An expression is just a piece of math or a value (like '2 + 2' or 'Hello').
Camel Case Naming
Programmers write multiple words by capitalizing the start of every word except the first. 'mySpaceshipSpeed'āit looks like the humps of a camel!
Rules for Naming Boxes
You can't name a box anything you want. No spaces are allowed, and it can't start with a number. 'myScore' is good, '1st Score' is illegal.
The 'const' Keyword
Sometimes you want a box that can never be opened or changed. We use 'const' for that. 'const gravity = 9.8' means gravity is locked in forever.
Changing Variables
The beauty of 'let' is that the box's contents can change. Later, you can say 'fuel = 50', and the computer throws out the 100 and replaces it with 50.
The 'let' Keyword
We create variables using the word 'let'. Typing 'let fuel = 100' tells the computer: 'Create a box named fuel, and put 100 inside it'.
What is a Variable?
A variable is just a labeled box. If you have a box labeled 'Score' and put the number 10 inside, the computer remembers that 'Score' means 10.
Your First Command
The classic first step is 'console.log()'. Using console.log('Hello, Earth!') is just you printing a message on that dashboard for yourself to read.
The Console Dashboard
Think of the console as your spaceship's dashboard. Itās a hidden panel where the computer talks to you. You can find it by right-clicking a webpage and selecting 'Inspect'.
Where does JS live?
JavaScript lives right inside your web browser. You don't need fancy software to run it; browsers like Chrome or Safari already have a built-in engine to understand it.
What is JavaScript?
Imagine a website is a house. HTML builds the walls, CSS paints them, but JavaScript wires the electricity. Itās what makes the house interactiveāturning on lights and opening doors.
Lecture 01: Introduction to Javascript
Total Duration: 1 hrs 52 mins 43 secs