Clear All Cookies with JavaScript

Shubham Vora
Updated on 23-Aug-2022 09:49:46

21K+ Views

In this tutorial, we will learn to clear all cookies using JavaScript. The cookies are the text or data stored in the format of text files in the browser or user's computer, and it is one kind of cache memory. The developer can store the username, authentication tokens, etc., in the browser's cookies. When a user visits the webpage for the first time, it retrieves the user information from the server and stores it in the cookie format in the browser. After that, when a user visits the webpage again, it retrieves the required data from cookies instead of the ... Read More

How Is Infinity Converted to Number in JavaScript

Shubham Vora
Updated on 23-Aug-2022 09:43:52

2K+ Views

A simple wrapper object is the number. Numerous methods and constants are available when using the Number function Object() { [native code] }. The Number() method may be used to transform values of different kinds into numbers. The IEEE 754 double-precision 64-bit binary value type is used in JavaScript. This indicates that it can represent fractional values, but the amount of data it can hold is constrained. Arithmetic is vulnerable to rounding, and a number only retains roughly 17 decimal places of precision. A Number may carry a maximum value of around 1.8E308. Higher values are substituted with the ... Read More

Make Print Button Without JavaScript

Shubham Vora
Updated on 23-Aug-2022 09:37:59

896 Views

In this tutorial, we will learn to make the print button without using JavaScript. Most of you have seen the print button on any website or application, and when users click on the print button, it prints the whole webpage or any particular file. However, the HTML doesn’t contain the print method. We can use the print() method of the window object. The window object is the global object, which can be accessed anywhere inside the code. So, either user can invoke the window.print() method from the JavaScript or HTML code.Syntax Users can follow the syntax below to invoke JavaScript's ... Read More

Extract Number of Minutes from Current Time in JavaScript

Shubham Vora
Updated on 23-Aug-2022 09:24:30

2K+ Views

We humans can understand how the date and time are divided and printed. On theother hand, JavaScript interprets the date based on a timestamp generated from Unix time, which is a value made up of milliseconds. JavaScript Platform-independent date objects represent a single point in time. A millisecond counter has been included in Date objects since January 1, 1970 UTC. YYYY-MM-DD is the most used JavaScript date format. Timed Dates YYYY-MM-D DTHH:MM:SSZ. A date data type is not available in JavaScript. Dates can be set, obtained, and changed using various methods provided on the Date object in JavaScript. In ... Read More

Extract Hostname Portion of a URL in JavaScript

Shubham Vora
Updated on 23-Aug-2022 09:20:54

11K+ Views

In this tutorial, we will see how to extract the hostname portion of a URL in JavaScript. What is a URL? An alternative term for a web address is a URL. For example, tutorialpoints.com is a word-based URL. An IP address can also be used as a URL (ex. 192.168.2.24). Since names are simpler to recall than numbers, most users submit the name’s address when searching on the internet A URL is a method by which web browsers ask web servers for specific pages. The syntax/format of a URL is given below. Syntax scheme://prefix.domain:port/path/filename Parameters scheme − specifies ... Read More

Execute JavaScript Function from String Name

Shubham Vora
Updated on 23-Aug-2022 09:18:14

2K+ Views

Calling a function from a string, stored in a variable can be done in two different ways. The first approach makes use of the window object method, and the second method makes use of the eval() function. This tutorial will guide you to learn the way to execute a JavaScript function using its name as a string. Using the window[]() Method Here, to execute the function using the function name as a string, the string should be changed to a pointer using the following syntax. Syntax var functionName = "string"; functionName = window[functionName]( parameters ); Here we have stored ... Read More

Execute JavaScript Function Using Its Name in a Variable

Shubham Vora
Updated on 23-Aug-2022 09:15:40

555 Views

What is a function in JavaScript? The JavaScript equivalent of a process is a function. A process is a series of instructions for carrying out a task or calculating a value. However, a process must accept input and produce a result to be considered a function. Additionally, there should be a clear connection between the input and the output. Follow the syntax below to define a function This tutorial will guide you to learn the way to execute a JavaScript function using its name in a variable. Syntax function functionName( param1, param2, param3 ) { //code } ... Read More

Encode a URL Using JavaScript Function

Shubham Vora
Updated on 23-Aug-2022 09:12:46

2K+ Views

As we know, a URL is a web address. What is URL encodingand why do we need to encode a URL? The process of turning a string into an accurateURL format is known as URL encoding. A valid URL format only uses "alpha | digit | safe | extra | escape" characters. Only a limited selection of the normal 128 ASCII characters is permitted in URLs. It is required to encrypt reserved characters that are not part of this set. The reliability and security of the URLs are increased with URL encoding. Each character that needs to be URL-encoded is ... Read More

Case Insensitive String Comparison in JavaScript

Shubham Vora
Updated on 23-Aug-2022 09:10:37

1K+ Views

In this tutorial, we will learn how to do a case-insensitive string comparison of strings in JavaScript. Case in-sensitive simply means the word or string should mean the same even if they are written in lower or upper case. In this kind of case in-sensitive comparison is observed in the google search bar, wherein if the user type “tUtoriAlsPOint” or “Tutorialspoint” the results are the same, similarly it is used in search bar too. There are 4 ways to do this, toUpperCase() toLowerCase() localeCompare() RegExp() Using the toUpperCase() Method When we use the toUpperCase() method on a string, ... Read More

Basic Maths with JavaScript Operators

Shubham Vora
Updated on 23-Aug-2022 09:05:28

290 Views

In this guide, we will explain the different methods to do basic maths with JavaScript operators. While creating any website, application, or game, you might have to show the calculated results, whether the number shows the subscriber count or the points of the user. Hence, learning how to add, subtract, and multiply using different data types in JavaScript is important. Using (+) Operator for Addition in JavaScript The binary operator to do basic maths in JavaScript is straightforward. However, the process can become a bit complex when you have to get the number as the output. This method will teach ... Read More

Advertisements