- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 10710 Articles for Web Development
![Mayank Agarwal](https://www.tutorialspoint.com/assets/profiles/333719/profile/60_290052-1619507248.jpg)
848 Views
You can use new Agent() method to create an instance of an agent in Node. The http.request() method uses the globalAgent from the 'http' module to create a custom http.Agent instance.Syntaxnew Agent({options})ParametersThe above function can accept the following Parameters −options – These options will contain the configurable options that could be set on an Agent while creation. Below are the fields/options the Agent can have −keepAlive – This method keeps the sockets around whether there are any outstanding requests or not, but keeps them for any future requests without actually re-establishing the TCP connection. One can use 'close' connection' to close this connection. ... Read More
![Mayank Agarwal](https://www.tutorialspoint.com/assets/profiles/333719/profile/60_290052-1619507248.jpg)
10K+ Views
The start-script of a Node.js application consists of all the commands that will be used to perform the specific tasks. When starting or initializing a Node.js project, there are a lot of predefined scripts that will be created for running the application. These scripts can be changed as per the need or demand of the project.Script commands are widely used for making different startup scripts of programs in both Node and React. 'npm start' is used for executing a startup script without typing its execution command.Package.json FileThis is the start-up script that needs to be added in the package.json file. ... Read More
![Mayank Agarwal](https://www.tutorialspoint.com/assets/profiles/333719/profile/60_290052-1619507248.jpg)
550 Views
The agent.createConnection() method is an interface provided by the 'http' module. This method produces a socket/stream that can be used for the HTTP requests. One can use custom agents to override this method for greater flexibility. A socket/stream can be returned in two ways – either by returning the socket/stream directly from this function, or by passing this socket/stream to the callback.Syntaxagent.createConnection(options, [callback])ParametersThe above function can accept the following parameters −options – These options will contain the connection details for which stream has to be created.callback – This will receive the created socket connection from the agent.ExampleCreate a file with the name ... Read More
962 Views
The art of sorting arrays is of paramount importance in the realm of programming, as it allows for efficient organization and manipulation of data. When it comes to implementing a reliable sorting algorithm, insertion sort emerges as a versatile and effective option. In this article, we delve into the intricate world of JavaScript to explore the process of implementing insertion sort to arrange an array of numbers in increasing order. By comprehending the underlying mechanics of this algorithm and harnessing the power of JavaScript's capabilities, developers can unlock the potential to efficiently sort and organize numerical data, enhancing the performance ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
69 Views
ProblemWe are required to write a JavaScript function that takes in a string str as the first and the only argument.The string str can contain three types of characters −English alphabets: (A-Z), (a-z)Numerals: 0-9Special Characters − All other remaining charactersOur function should iterate through this string and construct an array that consists of exactly three elements, the first contains all alphabets present in the string, second contains the numerals and third the special characters maintain the relative order of characters. We should finally return this array.For example, if the input to the function isInputconst str = 'thi!1s is S@me23';Outputconst output ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
87 Views
ProblemWe are required to write a JavaScript function that takes in an array of integers, arr, as the first argument and a number, num, as the second argument.Our function should find the contiguous subarray of given length num that has the maximum average value. And we need to output the maximum average value.For example, if the input to the function isInputconst arr = [1, 12, -5, -6, 50, 3]; const num = 4;Outputconst output = 12.75;Output ExplanationBecause the desired subarray is [12, -5, -6, 50]ExampleFollowing is the code − Live Democonst arr = [1, 12, -5, -6, 50, 3]; const num ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
90 Views
ProblemWe are required to write a JavaScript function that takes in an array of pairs of numbers, arr, as the first and the only argument. In every pair, the first number is always smaller than the second number.Now, we define a pair (c, d) that can follow another pair (a, b) if and only if b < c. Chain of pairs can be formed in this fashion. Our function is supposed to find the length longest chain which can be formed.For example, if the input to the function isInputconst arr = [ [1, 2], [2, 3], [3, 4] ];Outputconst ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
563 Views
ProblemWe are required to write a JavaScript function that takes in an array of sorted integers, arr, as the first argument and a target number, as the second argument.Our function should return an array of exactly two numbers that exists in the array arr and are closest to target. The output array should also be sorted in increasing order.For example, if the input to the function isInputconst arr = [1, 2, 3, 4, 5]; const target = 3;Outputconst output = [2, 3];ExampleFollowing is the code − Live Democonst arr = [1, 2, 3, 4, 5]; const target = 3; const findClosest ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
187 Views
ProblemWe are required to write a JavaScript function that takes in an array of sorted integers, arr, as the first and the only argument.Our function should return true if and only if we can split the array into 1 or more subsequences such that each subsequence consists of consecutive integers and has length at least 3, false otherwise.For example, if the input to the function isInputconst arr = [1, 2, 3, 3, 4, 5];Outputconst output = true;Output ExplanationWe can split them into two consecutive subsequences −1, 2, 3 3, 4, 5ExampleFollowing is the code − Live Democonst arr = [1, 2, ... Read More