Questions
JavaScript questions
Choose a question page, learn the concept, then test your understanding with a quiz.
How to Shuffle a JavaScript Array with Fisher-Yates
Learn how to randomly shuffle a JavaScript array using the unbiased Fisher-Yates algorithm, including copy-safe examples and common pitfalls.
How to Sort an Array of Objects by a String Property in JavaScript
Learn how to sort JavaScript arrays of objects by a string property using sort() and localeCompare() with clear examples.
How to Stop setInterval in JavaScript
Learn how to stop setInterval in JavaScript using clearInterval, events, and practical examples for timers and auto-refresh.
How to Store JavaScript Objects in localStorage and sessionStorage
Learn why localStorage stores strings only and how to save and retrieve JavaScript objects safely with JSON.stringify and JSON.parse.
How to Style Half of a Character in CSS and JavaScript
Learn how to style half of a letter using CSS and JavaScript, including overlay techniques, clipping, gradients, and dynamic text ideas.
How to Upload Files Asynchronously with jQuery and FormData
Learn how to upload files asynchronously with jQuery using FormData, AJAX, and the correct multipart settings.
How to Uppercase the First Letter of a String in JavaScript
Learn how to uppercase the first letter of a string in JavaScript without changing the rest of the text, with examples and common mistakes.
How to Validate Decimal Numbers in JavaScript
Learn how to validate decimal numbers in JavaScript, including negatives and leading decimals, with clear rules and practical examples.
JavaScript == vs ===: Which Equality Operator Should You Use?
Learn the difference between == and === in JavaScript, when to use each, type coercion rules, common pitfalls, and best practices.
JavaScript Closures in Loops: How to Capture the Correct Loop Variable Value
Learn why JavaScript closures in loops capture the wrong value and how to fix it using let, IIFEs, and function factories.
JavaScript DOM Ready Without jQuery: $(document).ready Equivalent
Learn how to replace jQuery's $(document).ready with native JavaScript using DOMContentLoaded and readyState.
JavaScript Default Parameters: Set Optional Function Argument Values
Learn how default parameters work in JavaScript functions, including syntax, examples, common mistakes, and practical use cases.
JavaScript Function Expressions vs Function Declarations
Learn the difference between JavaScript function expressions and function declarations, including hoisting, scope, pros, cons, and examples.
JavaScript Links: Should You Use href="#" or javascript:void(0)?
Learn why href="#" and javascript:void(0) are usually the wrong choice for JavaScript actions, and what to use instead.
JavaScript Pass by Value: Objects, References, and Function Arguments
Learn why JavaScript always passes arguments by value, how object reference values behave, and why object mutation differs from reassignment.
JavaScript Single vs Double Quotes for String Literals
Learn whether single and double quoted JavaScript strings are interchangeable, how escaping works, and how to choose a consistent style.
JavaScript Sleep: Why There Is No Real sleep() and What to Use Instead
Learn why JavaScript has no true sleep() on the main thread and how to pause work safely using setTimeout, Promises, and async/await.
JavaScript String Formatting Alternatives to printf and String.Format
Learn JavaScript alternatives to printf and String.Format, including number formatting, thousand separators, and date formatting.
JavaScript URL Encoding: escape() vs encodeURI() vs encodeURIComponent()
Learn when to use encodeURI and encodeURIComponent in JavaScript, why escape is deprecated, and how to safely build URL query strings.
JavaScript Variable Scope: Global, Function, and Block Scope
Learn JavaScript variable scope, including global, function, and block scope, and understand where global variables live in browsers and modules.