🖥️

JavaScript Overview and Basics

Aug 27, 2024

Introduction to JavaScript

Key Questions Answered

  • What is JavaScript?

    • Popular programming language.
    • Used by companies like Netflix, Walmart, and PayPal.
    • Average salary of a JavaScript developer in the US is $72,000.
    • Opportunities in front-end, back-end, and full-stack development.
  • What can you do with JavaScript?

    • Originally for building interactive web pages in browsers.
    • Now used for full-blown web/mobile apps, real-time apps (chat, video streaming), command-line tools, and games.
  • Where does JavaScript run?

    • In browsers with a JavaScript engine (e.g., SpiderMonkey in Firefox, V8 in Chrome).
    • Outside browsers using Node.js (created by embedding V8 in a C++ program).
  • JavaScript vs. ECMAScript?

    • ECMAScript: Specification by ECMA.
    • JavaScript: Language conforming to ECMAScript.
    • ECMAScript 2015 (ES6) introduced new features.

Writing JavaScript Code

  • Using Chrome Developer Tools

    • Right-click -> Inspect -> Console tab.
    • Can execute JavaScript directly.
  • Setting up Development Environment

    • Recommended tools: Visual Studio Code and Node.
    • Create a folder and use VS Code for organizing code.
    • Use Live Server extension for serving web apps.

JavaScript Basics

Variables

  • Use let to declare variables.
  • Variables can store strings, numbers, booleans, undefined, and null values.
  • Follow naming rules: meaningful, no reserved keywords, cannot start with numbers, no spaces or hyphens.

Constants

  • Use const for values that should not change.

Data Types

  • Primitives: Strings, numbers, booleans, undefined, null.
  • Reference Types: Objects, arrays, functions.
  • JavaScript is a dynamic language; types can change at runtime.

Objects

  • Used to group related variables as properties.
  • Access properties using dot notation or bracket notation.

Arrays

  • Used for lists of items.
  • Dynamic in size and content type.
  • Access elements by index.

Functions

  • Set of statements performing a task or calculating a value.
  • Can take inputs (parameters) and return outputs.
  • Function declarations use function keyword.

Advanced Usage

  • Functions can perform tasks or return values.
  • Arrays and objects enhance organization and manipulation of data.
  • Encouraged to explore further courses for in-depth learning.