JavaScript Basics
JavaScript makes web pages interactive.
About this topic
JavaScript is the programming language of the web. It runs in every browser to make pages interactive, such as showing menus, validating forms and updating content without reloading, and it can also run on servers with Node.js. Along with HTML for structure and CSS for style, it is one of the three core web technologies.
Basic ideas include variables declared with let or const, functions, conditionals, loops, arrays and objects. JavaScript works with the Document Object Model (DOM), a tree representation of the page, so code can find an element and change its text or style. Event listeners respond to clicks and key presses. For example, a button handler might change a heading to Hello when clicked.
Despite the similar name, JavaScript is not the same as Java. A common surprise is that the triple equals sign compares both value and type, while the double equals sign converts types first and can give odd results, so triple equals is usually safer. Another is that statements are often run asynchronously, so some code finishes later. Use the browser console to experiment and see errors.
Key ideas
- Runs in browsers
- Variables with let and const
- DOM manipulation
Quick check
Use cases: where JavaScript Basics helps
- Homework: review the key idea behind JavaScript Basics before you start a problem set.
- Exam revision: use the quick check to test whether you can recall JavaScript Basics without notes.
- Visual learning: play with the interactive lab to see how JavaScript Basics changes when you adjust its inputs.
- Teaching a friend: explain JavaScript Basics in your own words, then compare your version with the key ideas.
Computing ideas run phones, search engines, games and the wider internet.
Frequently asked questions
What is JavaScript Basics?
JavaScript makes web pages interactive.
What will I learn in JavaScript Basics?
Runs in browsers. Variables with let and const. DOM manipulation.
Is JavaScript Basics part of Computer Science?
Yes. It is one of 80 Computer Science topics on LearnViz HighSchoolEdu, with 3 key ideas, a live animation and a quick check.
Does the JavaScript Basics lab work on a phone or tablet?
Yes. The animation resizes to fit your screen and supports touch, so you can drag, tap and slide with your finger.
How should I study JavaScript Basics?
Read the summary and key ideas first, play with the interactive lab to see the idea in motion, then answer the quick check. If you get a question wrong, go back to the key idea it tests.
Do I need an account, and is my progress saved?
No account is needed. Marking a topic as learned is saved in your own browser, so it stays on that device and is not sent to a server.