Module 1: Introduction to JavaScript and Programming
Setting Up Your Environment
You have several options for writing and running JavaScript code:
-
Browser Developer Tools (Console):
- Every modern browser (Chrome, Firefox, Edge, Safari) comes with built-in developer tools.
- You can open the console (usually by right-clicking on a webpage, selecting "Inspect" or "Inspect Element", and then navigating to the "Console" tab) and type JavaScript code directly to see it execute.
- Great for quick tests and experiments.
-
Online Code Editors/Playgrounds:
- Websites like CodePen (https://codepen.io), JSFiddle (https://jsfiddle.net), and Replit (https://replit.com) provide an online environment where you can write HTML, CSS, and JavaScript and see the results instantly without any local setup.
-
Local Development with a Text Editor and Browser:
- Text Editor: Use a code editor like Visual Studio Code (VS Code - highly recommended), Sublime Text, or Atom to write your code.
- HTML File: Create an HTML file (e.g.,
index.html
). - Script Tag: Embed your JavaScript code within
<script>
tags in the HTML file, or link to an external.js
file. - Browser: Open the HTML file in your web browser to run the JavaScript.
-
Local Development with Node.js (for server-side or command-line JS):
- Install Node.js from https://nodejs.org.
- This allows you to run JavaScript files directly from your terminal (e.g.,
node myscript.js
). - Essential for back-end development and using many JavaScript build tools.