Section 1.2: Setting Up the Environment
Tutorial 1.2.1: Installing a Code Editor (e.g., VS Code)
Installing a Code Editor
To write and test JavaScript effectively, you need a code editor. While there are many options available, Visual Studio Code (VS Code) is one of the most popular choices due to its versatility and rich feature set.
Step-by-Step Guide to Installing VS Code
- Download VS Code:
- Visit the official VS Code website.
- Choose the version for your operating system (Windows, macOS, or Linux).
- Install VS Code:
- Follow the installation wizard for your operating system:
- Windows: Double-click the
.exefile and follow the on-screen instructions. - macOS: Drag the downloaded app into the Applications folder.
- Linux: Use the package manager or install from the terminal.
- Launch VS Code:
- Open the application after installation to ensure it's working correctly.
Enhancing VS Code for JavaScript Development
- Install Extensions:
- Open the Extensions view (
Ctrl+Shift+XorCmd+Shift+Xon macOS). - Recommended extensions for JavaScript:
- ESLint: Linting and error-checking.
- Prettier: Code formatting.
- JavaScript (ES6) Code Snippets: Useful code snippets.
- Live Server: Preview your code in the browser.
- Set Up Themes:
- Customize the editor's look by choosing a theme:
- Navigate to
File > Preferences > Color Theme. - Popular themes: Dark+, Dracula, Monokai.
- Enable Auto-Save:
- Go to
File > Preferences > Settingsand search for "Auto Save." - Set it to
afterDelayfor smoother development.
Testing JavaScript in VS Code
- Create a New File:
- Open VS Code and create a file with the
.jsextension (e.g.,test.js).
- Write and Save Code:
- Example:
console.log("Hello, World!");- Run JavaScript Code:
- Install Node.js (we’ll cover this in the next tutorial) to run JavaScript directly in the terminal.
- Open the integrated terminal (
Ctrl+~orCmd+~) and type:
node test.jsAlternative Editors
- Sublime Text: Lightweight and fast.
- Atom: Customizable and open-source.
- WebStorm: Paid but feature-rich, ideal for large projects.