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 Scroll Automatically to the Bottom of the Page in JavaScriptThis article teaches you about how to scroll automatically to the bottom of the page in JavaScript. It also educates you how to do scrolling with and without animation in JavaScript. How to Generate Permutations in JavaScriptPermutation is a mathematical concept of setting up maximum possible combinations of a given string or array. In JavaScript to result in such output, the drive is to use backtracking recursion method. How to Display Text When Checkbox Is Checked in JavaScriptThis tutorial guides you about how to display text when checkbox is checked in JavaScript. It also instructs about the use of jQuery function and events. How to Create A Count Up Timer in JavaScriptThis article demonstrates various ways to display a JavaScript count up timer using functions, objects and jQuery library. How to Create Simple Pagination in JavaScriptThis article will demonstrate how you can create pagination to surf on webpages using custom pagination functions and the jquery plugin, pagination.js. How to Convert an Image Into Base64 String Using JavaScriptThis article will discuss how to convert an image to its base64 string representation by creating a canvas and load the image into it, and using file reader method to get the corresponding string of an image. How to Check Whether an Element Contains a Class in JavaScriptLearn how to perform a check on an element in order to find out if it contains a specific class. How to Check if a Value Is NaN in JavaScriptThe goal of this tutorial is to provide you with multiple ways to check if a value is of type NaN in JavaScript. How to Return Multiple Values in JavaScriptJavaScript do not support functions that can return multiple values. But multiple values can be passed via array or object and later can be accessible. How to Parse Query String in JavaScriptThis tutorial describes how to use parse query string using function in JavaScript How to Detect Arrow Key Presses in JavaScriptThis tutorial describes how to use keyboard event listener in JavaScript. How to Open Local Text File Using JavaScriptThis tutorial demonstrates different methods to open local text file using JavaScript. It also exemplifies using FileReader, Promise, and jQuery. How to Iterate Through a Map in JavaScriptJavaScript allows iteration through an object by the help of key-value pair data structure aka the map. The iteration process operates in multiple ways like the pre ES6 format where we iterate through each element one by one, the for of, and the for each convention. How to Filter Object Arrays Based on Attributes in JavaScriptJavaScript objects can be used in a variety of forms. Using an object to form an array and retrieving filtered value from it based on attributes can be operated with the filter method. How to Create a Map Function for Objects in JavaScriptThis tutorial shows the methods you can use to map objects using a custom function to perform operations on the object's attributes in JavaScript. How to Check if a String Is a Valid JSON String in JavaScriptThis tutorial describes how to check if JSON string is valid or invalid in Javascript. How to Add Options to Select With JavaScriptThe manual possibility of adding option to select element can be altered with JavaScript. The Dom manipulation to create and append new options, initializing Option constructor to add options and the generic methods of joining new options will be discussed here. How to Return False in JavaScriptThis article explains the return false and preventDefault statements in JavaScript; when and where to use these statements and what is the difference between them. How to Use .forEach() to Iterate Over Elements in JavaScriptLearn how to iterate over elements in a collection using the .forEach() method and call a function to perform calculations on each element. How to Get the Value of Checked Checkbox in JavaScriptThis article introduces how to get the value of checked checkbox in JavaScript. How to Count Certain Elements of an Array in JavaScriptThis tutorial explains the way to count certain elements of an array of numbers by utilizing a method of the array entity as the filter or reduce method and the length property in JavaScript. How to Get Textbox Value in JavaScriptThis tutorial shows how can you get the value of a JavaScript textbox. How to Fire Ontextchanged Event of an Asp:TextBox via JavascriptHow to fire ontextchanged event of an asp:TextBox via Javascript? How to Overload Function in JavaScriptThis tutorial shows how you can implement the function overloading in JavaScript using if-else statement, switch statements and function expressions.