JavaScript Setup, Script Tags, Browser Console, Node.js, and First Program
Set up JavaScript in both browser and Node.js environments and understand how scripts are loaded and executed.
Inside this chapter
- Running JavaScript in the Browser
- Using External Files
- Node.js for Local Execution
- Your First Program
- Developer Tools Basics
- Common Setup Mistakes
Series navigation
Study the chapters in order for the clearest path from JavaScript basics and browser setup to asynchronous programming, APIs, performance, and advanced engineering practices. Use the navigation at the bottom to move smoothly through the full tutorial series.
Running JavaScript in the Browser
The browser is the most common first environment for JavaScript. Students can write scripts directly inside HTML or reference external JavaScript files. Browser developer tools also provide a console for quick experimentation and debugging.
<script>
console.log("Hello JavaScript");
</script> Using External Files
<script src="app.js"></script>
External files keep code maintainable, reusable, and easier to debug than large inline scripts.
Node.js for Local Execution
node app.js
Node.js allows JavaScript to run outside the browser. This is important because it broadens JavaScript into backend and tooling use cases.
Your First Program
console.log("Welcome to JavaScript");
This simple statement introduces output, execution flow, and the idea that JavaScript statements run in sequence.
Developer Tools Basics
Students should become comfortable with the browser console, element inspector, network panel, and sources panel early. JavaScript is much easier to learn when you can observe what the runtime is doing.
Common Setup Mistakes
- Referencing a wrong script path
- Loading a script before the HTML it depends on is available
- Assuming Node.js APIs work in browsers
- Ignoring console errors and warnings