How-to articles, tricks, and solutions about JAVASCRIPT

How to Check if a Variable is of Function Type

Read this JavaScript tutorial and learn several fast and useful methods that are invoked for checking whether the variable is of function type or not.

How to Measure Time Taken by a Function to Execute

Read this JavaScript tutorial and learn several fast and useful methods that are used to calculate the time taken by a function to execute in milliseconds.

How to Unset a JavaScript Variable

Read this JavaScript tutorial to know why you cannot delete the property that is created with var. Also, know in which cases you shouldn’t use the operator.

How to Check Whether an Object is a Date

Read this JavaScript tutorial and learn several ways that are used for checking whether the parameter passed to the method is of type Date object or not.

How to Sort an Array of Integers

Read this JavaScript tutorial and learn useful information about the logic of the sort() method which will help you sort an array of integers correctly.

How to Capitalize the First Letter in a String in JavaScript

Read this JavaScript tutorial and learn the methods and undertake some steps which will help you make the first letter in the string uppercase easily.

How to Get the First Character of a String

Read this JavaScript tutorial and learn several string methods that are used to retrieve the first character of a string. Choose the best one for you.

How to Sort Array Alphabetically in JavaScript

Read this JavaScript tutorial and learn the two methods of sorting the elements of an array in alphabetical order based on the values of the elements.

How to Get Image Size Using JavaScript

Read this tutorial and learn the two methods of getting the width and height of the image. Learn about the properties that help to get the image size.

How to Convert a String into a Date in JavaScript

Read this tutorial and learn the way of converting a string into a Date. Also, read about UTC method, ISO format and much more to get a relevant answer.

How to Get the First Key Name of a JavaScript Object

Read this JavaScript tutorial and learn about two methods of getting the first key name of an object. Get one-liner codes and make your work done properly.

How to Create a Dialog with JavaScript

Read this JavaScript tutorial and learn information about the method which can create a modal dialog with an optional message and “OK” and “Cancel” buttons.

Waiting Until All jQuery Ajax Requests are Done

Read this tutorial and learn useful information about the jQuery function that waits and then executes the function when all the ajax requests resolve.

How to Check if User Has Scrolled to the Bottom of the Page

Read this tutorial and learn information about jQuery method that is run for checking whether the user has scrolled to the bottom of the page or near to it.

How to Convert a Comma-Separated String into Array

Read this tutorial and learn information about the JavaScript built-in split() method which is called for converting a comma-separated string in an array.

How to Get the Difference Between Two Arrays in JavaScript

Read this tutorial and learn several JavaScript and jQuery methods that help you get the difference between two arrays easily. Choose the best one for you.

How to Check if an Enter Key is Pressed with jQuery

Read this tutorial and learn the right method of detecting whether the user pressed the Enter key. The given method provides a cross browser compatibility.

How to Make JavaScript Execute After Page Load

Read this JavaScript tutorial and learn which are the two most used methods of making the script execute as soon as the webpage has completely loaded.

How to Change the Image Source Using jQuery

Read this tutorial which will provide you with useful information about the best and easy method that can be used to change the image source using jQuery.

How to Check Whether a String Matches a RegEx in JavaScript

Read and learn two methods used to check whether a string matches RegEx in JavaScript. Also, see which method is the fastest and differences between them.

How to Get the Last Characters of a String

Read and learn several easy and simple methods you can use for retrieving the last characters of a JavaScript string. Choose the best method for your case.

How to Remove All CSS Classes Using jQuery/JavaScript

In this tutorial, you can read and learn several easy and simple jQuery methods and pure JavaScript properties that are used to remove all CSS classes.

How to Check for a Hash Value in a URL Using JavaScript

Read this tutorial and learn the fastest and simplest way of checking for a hash value in the URL using the window.location.hash method in JavaScript.

How to Center a <div> on the Screen Using jQuery

Read the tutorial and learn the jQuery method of centering the <div> element on the screen. Get a code snippet to add your script for centering the element.

How to Encode and Decode Strings with Base64 in JavaScript

Read this tutorial and learn useful information about two JavaScript built-in functions which are used to convert a string to and from base64 encoding.