Javascript Examples

Page 3 of 3

javascriptSnippet

Run A Function Only Once

Wrap sync and async functions so initialization runs at most once, sharing the cached result or in-flight promise.

javascriptSnippet

Sliding Window Maximum

Compute the maximum of every fixed-size window in O(n) using a monotonic deque, with clear handling of invalid sizes.

javascriptSnippet

Node.js JWT Auth with Express

Implement JWT authentication flow in Node.js Express with bcrypt password hashing, token signing and verification, refresh token endpoint, and protected.

javascriptSnippet

Node.js CLI with Inquirer

Build an interactive CLI tool in Node.js using Inquirer for prompts, chalk for colored output, and ora for spinners. Includes command chaining, template.

javascriptSnippet

Node.js Express File Upload

Handle file uploads in Node.js Express using multer middleware with disk and memory storage strategies, file filtering by MIME type, size limits, and.

javascriptSnippet

Vanilla JavaScript JWT Auth

Implement JWT authentication in vanilla JavaScript with token storage in localStorage, automatic token attachment to fetch requests, expiry checking, and.

javascriptSnippet

JavaScript Fetch with Caching

Implement a cached fetch wrapper in vanilla JavaScript using the Cache API with stale-while-revalidate strategy, request deduplication, and automatic cache.

javascriptSnippet

Vanilla JavaScript CLI Script

Build a command-line utility in vanilla JavaScript using process.argv parsing, readline for interactive prompts, chalk-free colored output with ANSI codes,.

javascriptSnippet

Vanilla JavaScript Data Fetching

Fetch and render remote data with vanilla JavaScript using async/await, AbortController for cancellation, loading state management, and error handling with.

javascriptSnippet

Vanilla JavaScript File Upload

Upload files with vanilla JavaScript using XMLHttpRequest for progress tracking, drag-and-drop support, file type validation, and chunked upload for large.

javascriptSnippet

Vue 3 File Upload Component

Build a file upload component in Vue 3 with drag-and-drop, progress bar, multiple file support, preview thumbnails for images, and automatic upload with.