Essential Javascript for Beginners

Aug 22, 2024

Beginner’s Javascript Course Notes

Introduction

  • Instructor: Beau Carnes from freeCodeCamp.org
  • Course Purpose: To teach beginners everything about Javascript and provide a refresher on basic Javascript syntax.
  • Standalone Video: Can be used without the freeCodeCamp.org curriculum, but might be beneficial to use alongside it.
  • Project Building: Encouragement to build personal projects after coursework to enhance learning.

Setting Up Javascript

  • Installation: Javascript does not require installation as it's supported by all web browsers.
  • Code Editors: Recommendations include Sublime Text, Visual Studio Code, Atom.
  • Using HTML: Creating an HTML file with <script> tags to write Javascript.
  • Console.log: Use in the console to display output (e.g., console.log("Hello World")).

Options for Writing Javascript

  1. freeCodeCamp Code Editor: Built-in editor with a console.
  2. CodePen: Online IDE for HTML, CSS, and Javascript with separate windows for each language.
  3. Scrimba: A tool used for recording the course, offering a unique console experience.

Comments in Javascript

  • Single-line Comments: Use // for inline comments.
  • Multi-line Comments: Use /* comment */ format.

Data Types and Variables

  • Data Types:
    • Undefined, Null, Boolean (true/false), String, Symbol, Number, Object.
  • Declaring Variables:
    • var, let, const.
    • var has function scope, let has block scope, const cannot be reassigned.

Assigning Values

  • Assignment Operator: Uses = to assign a value to a variable, e.g., var a = 7;
  • Using console.log: To debug and print variable values.

Arithmetic Operations

  • Basic Operations: Addition +, Subtraction -, Multiplication *, Division /, Increment ++, Decrement --.
  • Remainder Operator: % finds the remainder of a division.

Arrays and Their Properties

  • Defining an Array: var myArray = [1, 2, 3];
  • Accessing Elements: Use indexes (0-based)
  • Modifying Arrays: Use methods like push(), pop(), shift(), unshift().
  • Nested Arrays: Arrays within arrays, can be accessed using multiple indexes.

Functions and Scope

  • Function Declaration: Use the function keyword followed by parameters.
  • Return Statement: Use return to send a value back from a function.
  • Global vs Local Scope: Variables defined outside functions are globally scoped, while those inside are locally scoped.
  • Arrow Functions: A concise way to write functions with the => syntax.

Objects in Javascript

  • Creating Objects: Use curly braces {} to define key-value pairs.
  • Accessing Properties: Use dot notation (e.g., object.property) or bracket notation (e.g., object['property']).
  • Adding/Deleting Properties: You can manipulate object properties using delete keyword.

ES6 Features

  • Destructuring Assignment: Simplifies extracting values from arrays/objects.
  • Template Literals: Allows embedding expressions in strings using backticks ``.
  • Modules: Use import and export to share code across files.

Conclusion

  • Encouragement to practice and create personal projects.
  • Reminder to subscribe to freeCodeCamp for more resources and learning opportunities.