
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
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
Found 6710 Articles for Javascript

2K+ Views
For a given linked list, write a program in JavaScript to find its middle element. Here, linked lists are a type of linear data structure. If there are an even number of elements in the linked list, there will be two middle nodes. In this case, the middle element would be the latter element out of both elements. Example Scenario: Input: linked_list = 1->2->3->4->5->6-> null Output: middle_element = 4 Using Iteration Iterate over the whole list and count the number of nodes. Now, iterate over the node till count/2 and return the count/2 i.e. the middle element. Example ... Read More

183 Views
In this article, we are going to explore the 'in' operator and how to use it in JavaScript. The in operator is an inbuilt operator in JavaScript that is used for checking whether a particular property exists in an object or not. It will return true if the property exists, else false is returned.Syntaxprop in objectParametersThis function accepts the following parameters as described below −prop − This parameter holds the string or symbol that represents a property name or the array index.object − This object will be checked if it contains the prop or not.Return value − This method will ... Read More

3K+ Views
The keyword "Static" is used for defining a static method or a static property of a class. The benefit of a static method is that we do not need to create an instance or object of the class. It does not have multiple values. It will have a single static value defined during initialization.The keyword static is similar to the const keyword. It is set at the run time when the initialization takes place and these types of variables have global presence and scope. We can use these static variables anywhere over the script.Note − We can reassign and change ... Read More

2K+ Views
In this article, we are going to explore a way to convert the JSON text into a JavaScript object. JSON, also known as JavaScript Object Notation, is a lightweight data-interchange format that is used for exchanging data over web browsers. JSON is derived from the JavaScript programming language but can be used by various other languages also including Python, Java, PHP, Ruby, etc. It is also language-dependent.A JSON mainly follows a key-value data format that saves a value associated with a key. A JSON object consists of curly braces ({}) at both ends to define the starting and ending of ... Read More

272 Views
The Destructuring assignment is a feature that was introduced in the ECMAScript 2015. This feature lets the user extract the contents of the array, and properties of an object into distinct variables without actually writing the repetitive codeThis assignment lets the expression unpack values from arrays, and properties into distinct variables.Example 1In the below example, we use the destructuring assignment to assign variables. In the example, we have two variables defined as first and second. In the method, we are destructing the variables to assign the variables of the array to x and y respectively.# index.html Checking ... Read More

2K+ Views
In this article, we are going to look at some cursor settings and their behaviors. Currently, there are different kind of cursors as provided by any system that includes a pointer, hand, insert, wait, pointer-wait, and many others.With the help of this article, we would be able to configure the wait pointer when required. This pointer will prevent the user from clicking a button unnecessarily and stops any further execution of similar events until the previous event is completed.We can directly use the CSS property to display the cursor as waiting but since we need the dynamic impact on showing ... Read More

621 Views
Searching strings for specific patterns is a common task in JavaScript. Strings are data types and are represented as a sequence of characters. Searching patterns means verifying the presence of a specific pattern in a given string. A pattern would be a specific word, specific characters, and so on. JavaScript offers several powerful methods for pattern matching, such as inbuilt string methods and regular expressions. This article will guide you on how to search strings for specific patterns in JavaScript. Table of contents Searching strings for specific patterns in JavaScript can be done in the following ways: ... Read More

2K+ Views
In this article, we will learn to check if the browser tab page is focused and under use or not in JavaScript. This is mainly required to record the user’s inactivity time on the app and then take any action upon it if required. Use Cases for Monitoring Browser Tab Focus Following are the use cases for monitoring browser tab focus and user inactivity − Prevent sending the network request if the page is not being used by the user as this would reduce the traffic on the server. This would ... Read More

437 Views
In this article, we will explore the essentials of a regular expression (RegEx) and how to compare other strings with this regex in JavaScript. We will learn how to identify a similar string with that of a regex and then subsequently return them. We can use the string.search() method to match the regular expression in a given string.Syntaxlet index = string.search(expression)Parametersstring − This is the string that will be searched in comparison with the expression.expression − This is the regular expression that will be used for checking with the original string.Example 1In the below example, we are going to compare ... Read More

907 Views
In this article, we are going to explore replacing a portion of a string with another value using JavaScript. We can replace string parts in multiple ways. Below are some common methods −replace() methodsplit() methodjoin() methodLet’s discuss the above methods in detail.The replace() MethodThis is an inbuilt method provided by JavaScript that allows the user to replace a part of a string with some another string or a regular expression. However, the original string will remain the same as earlier.Syntaxstring.replace(searchvalue, newvalue)Parameterssearchvalue - It is used for searching a string in the whole string.newvalue - It will replace the searched string.The ... Read More