

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
URLSearchParams.has & delete() in Node
Introduction to has()
This function returns true or false based upon the query argument. The function will return true if name-value pair exists for the argument.
Syntax
var bool = URLSearchParams.has(name);
It will return TRUE if name is present, else FALSE.
Parameters
The input parameter is a name that needs to be searched in the URL.
Example
// Defining the URL as a constant const myURL = new URL( 'https://example.org/?firstName=John'); // Printing whether the argument exists or not console.log(myURL.searchParams.get('firstName'));
Output
true
Example
// Defining the URL as a constant const myURL = new URL( 'https://example.org/?firstName=John'); // Printing whether the argument exists or not console.log(myURL.searchParams.get('lastName'));
Output
false
Introduction to delete()
It will delete/remove the occurence of the passed argument.
Syntax
URLSearchParams.delete(name);
It will return a modified URL after removing the passed argument.
Parameters
The name is passed that needs to removed from the URL.
Example
// Defining the URL as a constant const params = new URLSearchParams( 'firstName=John&lastName=Chan'); console.log(params.toString); // Removing the 'firstName' parameter params.delete('firstName'); console.log(params.toString());
Output
firstName=John&lastName=Chan lastName=Chan
Example (When arg does not exist)
// Defining the URL as a constant const params = new URLSearchParams( 'firstName=John&lastName=Chan'); console.log(params.toString); // Removing the 'firstName' parameter params.delete('midName'); console.log(params.toString());
Output
firstName=John&lastName=Chan firstName=John&lastName=Chan
- Related Questions & Answers
- URLSearchParams entries & forEach in Node
- URLSearchParams sort & toString() in Node
- URLSearchParams values & keys() in Node
- Delete Node in a BST in C++
- Golang program to delete the node after the Kth node.
- Delete Node in a Linked List in Python
- Introduction to URLSearchParams API in Node.js
- Delete a node in a Doubly Linked List in C++
- Delete a Node from linked list without head pointer in C++
- Delete a Linked List node at a given position in C++
- Golang Program to delete the node after the Kth node (K is not in the linked list).
- Delete a Doubly Linked List node at a given position in C++
- Golang Program to delete the first node from a linked list.
- Golang Program to delete the last node from a linked list.
- Check if each internal node of a BST has exactly one child in Python
Advertisements