Beginner Topic 12 of 51 Web Development
JavaScript Basics
Core scripting language of the browser.
How it works
JavaScript is the programming language of the web, running in browsers and on servers via Node.js. It has dynamic typing, first-class functions, objects with prototypes, closures, classes, template strings, destructuring, spread syntax and modules. Variables are declared with let and const, and values are primitives, such as numbers and strings, or objects. Equality has strict and loose forms, and the language is single-threaded with an event loop.
Step-by-step walkthrough
- A script is loaded with the page.
- The engine executes it line by line.
- Code stores values and defines functions.
- It can change the page and react to the user.
- JavaScript is single-threaded and uses events for responsiveness.
Where it is used
Interactive pages, form validation, single-page applications, servers, command-line tools and mobile and desktop apps use JavaScript.
Common pitfall
Loose equality with == and implicit type coercion create surprising results, such as 0 == '' being true; use ===. Variable hoisting and the value of this depend on how functions are called. Floating-point math and undefined versus null confuse beginners. Use strict mode, linters and TypeScript to catch problems early.
Where it fits in the course
JavaScript Basics is topic 12 of 51 in Web Development, rated Beginner. It follows Media Queries. The next topic is DOM.
Practice and explore
- Open the interactive lesson, with a mini quiz.
- Take the Web Development quiz.
How to study this topic
- Read the explanation above and restate the definition in your own words.
- Open the interactive lesson and answer its mini quiz.
- Read the common pitfall, then write a short example that avoids it.
- Check your understanding in the Web Development quiz, and revisit the topic if you miss a question.
Frequently asked questions
What is JavaScript Basics?
Where do people use JavaScript Basics?
What is the most common mistake with JavaScript Basics?
What should I learn before this topic?
How can I practice it?
Is JavaScript Basics hard to learn?
How long does it take to learn JavaScript Basics?
Which topics are related to JavaScript Basics?
What should I study after JavaScript Basics?
Related topics
- Media Queries (Web Development)
- DOM (Web Development)
- Responsive Design (Web Development)
- Events (Web Development)
- Algorithm Basics (Algorithms)
- Command Line Basics (DevOps & Tooling)
- Android Basics (Mobile, Embedded & IoT)