Practical solutions

JavaScript How-to Guides How-To Guides

Solve the problem. Keep building. A collection of practical JavaScript how-to guides

Find the answer you need

Browse practical solutions, grouped by the task you're working on.

__COUNT__ entries on this page

How to Hide Table Rows in JavaScriptUse jQuery toggle() to switch selected table rows between hidden and visible, or use show() and hide() with separate controls. How to Change CSS Classes in JavaScriptLearn how to change an element's CSS classes with className and classList, including a click-driven example. How to Create and Run a JavaScript File in ChromeRun a quick JavaScript Snippet in Chrome DevTools or load a saved JavaScript file from a local page served with Node.js and Express. How to Decode HTML Entities Using JavaScriptDecode HTML entities in a string with a browser textarea or the he package in Node.js. How to Print PDF File in JavaScriptLearn how to request browser printing for a PDF with a JavaScript iframe or the Print.js library. How to Call Multiple JavaScript Functions in Onclick EventThis tutorial introduces various ways in JavaScript to call more than one functions in onclick. How to Get Key of a JavaScript ObjectThis tutorial details how to get key of an object in javascript. Modulo Operator(%) in JavaScriptLearn how JavaScript's % operator returns a remainder, how negative operands and special numeric values behave, and how to use it for parity, fractional parts, intervals, turns, and time conversion. Nested Functions in JavaScriptLearn how nested functions in JavaScript work, how closures preserve access to outer variables, and when this pattern helps keep code organized. How to Scroll to ID in JavaScriptScroll to an element by ID with a native anchor or JavaScript. Use scrollIntoView() for the usual case, window.scrollTo() for a custom offset, and container scrolling for nested content. JavaScript Lambda FunctionLearn how JavaScript arrow functions work, how they differ from regular functions, and when to use each form. JavaScript 2D ArrayLearn how to create a JavaScript 2D array with nested array literals, loops, Array.from(), or map(), then initialize and access its cells safely. How to Submit Form Using JavaScriptThis tutorial teaches how to submit a form using JavaScript How to Get the First Element of an Array in JavaScriptGet the first JavaScript array element with array[0], or choose destructuring, find(), or shift() when their behavior fits. How to Pass JavaScript Function as ParameterLearn how to pass a JavaScript function as an argument, combine it with other values, use callbacks, and return a function from another function. How to Disable JavaScript in Google Chrome Developer ToolsLearn how to disable JavaScript on web pages from the Chrome developer tools Settings panel. How to Print Array Elements in JavaScriptThis tutorial shows different ways to print all or a certain number of JavaScript array elements. How to Get Height of the Div Element in JavaScriptThis tutorial introduces how to get the height of a div element inside JavaScript. How to Stop a setInterval() Timer in JavaScriptStop a repeating JavaScript timer by saving the identifier returned by setInterval() and passing it to clearInterval(). How to Convert a String Into a Date in JavaScriptLearn how to convert standard and custom date strings into JavaScript Date objects, and how to handle time zones and invalid input. Case Insensitive String Comparison in JavaScriptThis article explains how to perform comparisons between case insensitive strings in JavaScript. Discover various methods including toLowerCase, toUpperCase, localeCompare, and regular expressions to enhance your string comparison techniques. Perfect for developers looking to improve user experience and ensure reliable string handling in their applications. How to Insert Variable Into String in JavaScriptLearn how to insert variables into JavaScript strings with template literals, console formatting, and sprintf-js. How to Check if a Value Is Object in JavaScriptIn this tutorial we will check if a value is an object in JavaScript JavaScript Equivalent to Printf or String.FormatThis tutorial describes how to replicate the functionality of printf() in JavaScript. Explore various methods like template literals, Intl.NumberFormat, and the sprintf-js library to format strings effectively. Enhance your JavaScript skills with practical examples and detailed explanations for each approach.