javascript
// 1. localStorage basics
// Store data
localStorage.setItem('username', 'alex');
localStorage.setItem('theme', 'dark');

// Retrieve data

LocalStorage, SessionStorage, and IndexedDB

javascript localstorage indexeddb
by Alex Chang 1 tab
javascript
// 1. DANGEROUS: Never use innerHTML with user input
const userInput = '<img src=x onerror="alert('XSS')">';

// WRONG - vulnerable to XSS
document.getElementById('output').innerHTML = userInput;

Front-end security - XSS and CSRF prevention

security xss csrf
by Alex Chang 1 tab
javascript
// 1. Basic Custom Element
class MyButton extends HTMLElement {
  constructor() {
    super();

    // Attach shadow DOM

Web Components and Shadow DOM encapsulation

web-components shadow-dom custom-elements
by Alex Chang 1 tab
javascript
// service-worker.js

const CACHE_NAME = 'my-pwa-cache-v1';
const urlsToCache = [
  '/',
  '/index.html',

Progressive Web Apps - service workers and offline support

pwa service-workers offline-first
by Alex Chang 3 tabs
javascript
import React, { lazy, Suspense, useState, useEffect } from 'react';

// 1. Component lazy loading
const HeavyComponent = lazy(() => import('./HeavyComponent'));
const AdminPanel = lazy(() => import('./AdminPanel'));
const Dashboard = lazy(() => import('./Dashboard'));

Performance optimization - lazy loading and code splitting

performance optimization lazy-loading
by Alex Chang 2 tabs
javascript
import React, { createContext, useContext, useReducer, useState } from 'react';

// 1. Basic Context
const UserContext = createContext(null);

function UserProvider({ children }) {

State management with Context API and Redux patterns

react redux state-management
by Alex Chang 2 tabs
javascript
import React, { useState, useEffect, useCallback, useMemo, useRef, useContext } from 'react';

// 1. useState - managing component state
function Counter() {
  const [count, setCount] = useState(0);
  const [name, setName] = useState('');

React hooks - useState, useEffect, and custom hooks

react javascript hooks
by Alex Chang 1 tab
javascript
// ES6 Class syntax
class Person {
  constructor(name, age) {
    this.name = name;
    this.age = age;
  }

JavaScript classes and prototype-based inheritance

javascript classes oop
by Alex Chang 1 tab
javascript
// math.js - Named exports
export const PI = 3.14159;
export const E = 2.71828;

export function add(a, b) {
  return a + b;

JavaScript ES6 modules: import, export, and module patterns

javascript modules es6
by Alex Chang 1 tab
javascript
// Basic try-catch
try {
  const result = riskyOperation();
  console.log('Success:', result);
} catch (error) {
  console.error('Error occurred:', error.message);

Error handling and debugging techniques in JavaScript

javascript debugging error-handling
by Alex Chang 1 tab
javascript
// Basic GET request
fetch('https://api.example.com/users')
  .then(response => {
    console.log('Status:', response.status);
    console.log('OK:', response.ok);
    return response.json();

Fetch API for HTTP requests and AJAX communication

javascript fetch api
by Alex Chang 1 tab
javascript
// Creating elements
const div = document.createElement('div');
div.id = 'container';
div.className = 'box rounded';
div.textContent = 'Hello World';

DOM manipulation best practices and performance optimization

javascript dom manipulation
by Alex Chang 1 tab