Module 1: Introduction to JavaScript and Programming
Client-Side vs. Server-Side Scripting
Scripting languages can run in different environments:
-
Client-Side Scripting:
- Code is executed on the user's computer, typically within a web browser.
- JavaScript is the most common client-side scripting language.
- Pros: Can respond quickly to user actions without needing to communicate with the server, reduces server load, allows for richer user interfaces.
- Cons: Dependent on the user's browser capabilities, code is visible to the user (can be viewed/copied).
-
Server-Side Scripting:
- Code is executed on the web server.
- Examples: Node.js (JavaScript), Python (Django/Flask), PHP, Ruby on Rails.
- Pros: Can access databases and other server-side resources securely, code is not visible to the client, can handle complex business logic.
- Cons: Requires a round trip to the server for every dynamic request, which can introduce latency.
JavaScript, with Node.js, can be used for both client-side and server-side scripting, making it a full-stack development language.