Practical solutions

JavaScript Howtos How-To Guides

Solve the problem. Keep building. Collection of JavaScript how-to articles

Find the answer you need

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

__COUNT__ entries on this page

How to Check if Cookie Exists in JavaScriptIn this post, we will tackle the fundamentals of cookies and how to check if a cookie exists or not using JavaScript. How to Debug JavaScript Code With Visual Studio IDE on ChromeIn this tutorial, we'll see how to debug JavaScript code using the Microsoft Visual Studio IDE and chrome browser. How to Copy Text to Clipboard in JavaScriptIn this article, we will introduce how to copy text to the clipboard in JavaScript. How to Unminify JavaScript FileThere are tools out there to unminify JavaScript. In this article, we will learn about unminify process and how to unminify JavaScript code using some of the available tools. How to Create and Run a JavaScript File in ChromeIn this article, we will see how we can create and run the JavaScript code in the Chrome browser. How to Capitalize the First Letter of a String in JavaScriptIt demonstrates different ways to make the first letter of a string uppercase in JavaScript How to Copy Objects in JavaScriptIn this article, we will see how to make a copy of an object in JavaScript. How to Import Function From Another JS FileThis tutorial demonstrates how we can call a JavaScript function from one JS file into another JS file on local machine. It also exemplifies the use of ES6 import and export functions using live server in Visual Studio code. How to Check Whether a String Matches a Regex in JavaScriptMatching strings with a certain regular expression in JavaScript can be done in multiple ways. The most common techniques are the test(), match(), exec(), and matchAll() methods. JavaScript Lexical ScopeThis tutorial introduces the lexical scope in JavaScript. How to Validate URL in JavaScriptFor validating a URL, we can use the URL constructor of JavaScript to fetch a string. Also, we can manipulate the DOM, create an anchor tag, and pass the string as a href. Another approach is to match the URL with a certain regex that has a protocol, hostname pattern. JavaScript PointersJavaScript does not have an explicit way to define the pointers. It allows to pass values and references from object to object, but the reference cannot be displayed. This article will fine ways to define pointers in JavaScript. How to Strip Non-Numeric Characters From String in JavaScriptThis tutorial shows how you can remove the non-numeric characters from a string in JavaScript. How to Detect Memory Leak Detection in JavaScriptThis article educates about memory leak detection and prevention techniques in JavaScript. How to Prepend Elements in JavaScriptThis article educates how we can use different methods to prepend elements using JavaScript. How to Get Height and Width of the Element in JavaScriptThis article demonstrates how we can get the height and width of the element in JavaScript. JavaScript nextSibling PropertyThe JavaScript property nextSibling allows to present the following nodes after a certain node element. This nodes can be an element node, text node or comment node. Specifically, the nextSibling property does not ignore any nodes in between and grabs the serial from top to bottom. How to Swap Array Elements in JavaScriptSwapping elements of an array in JavaScript is performed manually. Unlike other programming languages, JavaScript does not support any built-in swap method. The most acceptable way to swap array elements is to use a temporary variable and use ES6 destructing assignment. Other than these, there are multiple logical ways of dealing with this task. How to Get Parent in JavaScriptTo get the track of an HTML structure, JavaScript has properties to figure out children and parent node and elements. Specifically, to retrieve the parent elements, the parentNode and parentElement properties are pretty handy. JavaScript Variable Number of ArgumentsJavaScript has the flexibility of dealing with an indefinite number of arguments in a function. This type of function is named after the variadic functions. The arguments object portrays as similar to an array element but it does not support any other properties like an array except the length. This along with the rest parameter effortlessly do their job of handling variable number of arguments. How to Use the setHours() Method in JavaScriptThe JavaScript setHours() enables to set the user-defined hour, minute, or second. It does not always require all of the parameters. But one defined parameter can set the time zone of preference. How to Check for a Hash in a URL in JavaScriptTo get the verdict if the current or any given URL has a hash, many ways can be considered. The jQuery convention and the basic split() method can work parallelly to identify the presence of a hash. Difference Between Event Bubbling and Capturing in JavaScriptThis article demonstrates the difference between event bubbling and capturing in JavaScript. How to Fill A JavaScript ArrayTo fill an array with user specified number or string, a wide range of JavaScript methods can be used. Amongst all, the fill() method is explicit in terms of setting any value for a defined length array. Also, the basic way of filling array elements with for loop, use of map() method, from() method, apply() methods are equally effective.