Front-end developer with 10+ years building modern web applications. Expert in responsive design, performance optimization, and accessibility. Passionate about creating...
/* 1. Mobile-first approach */
/* Base styles for mobile */
.container {
width: 100%;
padding: 1rem;
}
// 1. Basic types
let username: string = 'Alex';
let age: number = 30;
let isActive: boolean = true;
let items: string[] = ['item1', 'item2'];
let numbers: Array<number> = [1, 2, 3];
// 1. Create SVG elements
const svgNS = 'http://www.w3.org/2000/svg';
function createSVGElement(type, attributes = {}) {
const element = document.createElementNS(svgNS, type);
Object.entries(attributes).forEach(([key, value]) => {
// Get canvas and context
const canvas = document.getElementById('myCanvas');
const ctx = canvas.getContext('2d');
// 1. Basic shapes
// Rectangle (filled)
// 1. Basic WebSocket connection
const socket = new WebSocket('wss://example.com/ws');
// Connection opened
socket.addEventListener('open', (event) => {
console.log('Connected to WebSocket server');
// 1. localStorage basics
// Store data
localStorage.setItem('username', 'alex');
localStorage.setItem('theme', 'dark');
// Retrieve data
// 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;
// 1. Basic Custom Element
class MyButton extends HTMLElement {
constructor() {
super();
// Attach shadow DOM
// service-worker.js
const CACHE_NAME = 'my-pwa-cache-v1';
const urlsToCache = [
'/',
'/index.html',
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'));
import React, { createContext, useContext, useReducer, useState } from 'react';
// 1. Basic Context
const UserContext = createContext(null);
function UserProvider({ children }) {
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('');