Questions
JavaScript questions
Choose a question page, learn the concept, then test your understanding with a quiz.
Detect a Click Outside an Element in jQuery
Learn how to detect clicks outside an element in jQuery to close menus, modals, and dropdowns with clear examples and common pitfalls.
Disable an ESLint Rule for One Line in JavaScript
Learn how to disable a specific ESLint rule for one JavaScript line, a code block, or an entire file using ESLint directive comments safely.
Extract Object Property Values with JavaScript Array.map()
Learn how to extract one property from an array of JavaScript objects using Array.map(), computed keys, and safe handling of missing values.
Find an Object in a JavaScript Array by Property Value
Learn how to search an array of JavaScript objects by ID using find(), filter(), and jQuery, including safe type handling and examples.
Format Numbers With Thousands Separators in JavaScript
Learn how to format numbers with commas as thousands separators in JavaScript using toLocaleString, Intl, and custom methods.
Generate Random Integers in a Range in JavaScript
Learn how to generate random whole numbers between two values in JavaScript, including inclusive ranges, formulas, examples, and common mistakes.
Generate a Random Number in a Range in JavaScript
Learn how to generate random numbers between two values in JavaScript, including inclusive ranges, formulas, examples, and common mistakes.
Generate a Random String in JavaScript
Learn how to generate a fixed-length random string in JavaScript using a custom character set like a-z, A-Z, and 0-9.
Get Screen, Page, and Browser Window Size in JavaScript
Learn how to get screen size, viewport size, page size, and scroll position in JavaScript across major browsers with clear examples.
Get an HTML Element’s X and Y Position in JavaScript
Learn how to retrieve an HTML element’s X and Y coordinates in JavaScript with getBoundingClientRect, scroll offsets, and practical examples.
Get the Last Array Item in JavaScript
Learn how to access last, second-last, and conditional array items in JavaScript, with URL path examples and safer indexing patterns.
Get the Selected Radio Button Value with jQuery
Learn how to find the selected radio button in a form with jQuery using :checked, read its value, and handle common mistakes.
How AngularJS Data Binding and the Digest Cycle Work
Learn how AngularJS detects model changes with dirty checking, watchers, and the digest cycle, including when to use $apply for external code.
How JavaScript Closures Work: A Beginner-Friendly Guide
Learn how JavaScript closures work with simple explanations, examples, common mistakes, and practical use cases for real code.
How JavaScript Prototype Works: Constructors, Inheritance, and new
Learn how JavaScript prototypes work, how constructor functions and new create objects, and how prototype-chain method lookup works.
How to Add Elements to the Beginning of an Array in JavaScript
Learn how to prepend elements to the start of a JavaScript array using built-in methods like unshift and practical examples.
How to Append Items to an Array in JavaScript
Learn how to append strings, numbers, and objects to arrays in JavaScript using push, spread syntax, and immutable patterns.
How to Change an Element's Class with JavaScript
Learn how to change, add, remove, and toggle an HTML element's class with JavaScript using events like click.
How to Check If a Variable Exists in JavaScript
Learn the correct ways to check whether a variable is defined, initialized, null, or truthy in JavaScript with examples.
How to Check If a Variable Is a String in JavaScript
Learn how to check whether a variable is a string in JavaScript using typeof, instanceof, and safe patterns with clear examples.