Found 9150 Articles for Object Oriented Programming

JavaScript RegExp W Metacharacter

Ayush Gupta
Updated on 18-Sep-2019 12:32:45

246 Views

The \W metacharacter is used to find a non-word character.A word character is a character from a-z, A-Z, 0-9, including the _ (underscore) character.Example// Containing any non word character: console.log(/\W/.test(" ")) console.log(/\W/.test(".!@#")) // Not containing non word characters: console.log(/\W/.test("a")) console.log(/\W/.test("B")) console.log(/\W/.test("9")) console.log(/\W/.test("_"))Outputtrue true false false false false

Difference Between LinkedList and LinkedHashSet in Java

Aishwarya Naglot
Updated on 21-Apr-2025 19:15:46

2K+ Views

LinkedList and LinkedHashSet are two important classes of Java's Collection framework. They are used to store groups of items, but they work in different ways and have their own unique features. What is a LinkedList in Java? Java LinkedList is a linear data structure that is used to store the same type of elements. It is a part of the Java Collections Framework, and it implements the List as well as the Deque interfaces. It has a dynamic size, which means it can grow and shrink as needed. Example The following is an example of how we write code for ... Read More

JavaScript RegExp s Metacharacter

Ayush Gupta
Updated on 18-Sep-2019 12:26:19

135 Views

The \s metacharacter is used to find a whitespace character.A whitespace character can be −A space characterA tab characterA carriage return characterA new line characterA vertical tab characterA form feed characterExample// Not containing any white spaces: console.log(/\s/.test("1")) console.log(/\s/.test("test")) // Containing whitespace characters: console.log(/\s/.test(" ")) console.log(/\s/.test("a\tb")) console.log(/\s/.test("mn"))Outputfalse false true true true

Difference between length of Array and size of ArrayList in Java

Nitin Sharma
Updated on 18-Sep-2019 12:23:03

625 Views

In collections, one of the main functional requirement is to get the number of elements which are get stored in our collection so that one can decide whether to put more elements in it or not. Also, the number of elements is also required for iteration of collection.As we know Array and Arraylist both are used to store elements but both have different defined methods in order to know the number of elements stored in it.The array has a length method that provides the number of elements can be stored or in simple words capacity of the Array. Also, the ... Read More

Difference between Java and JavaScript.

Aishwarya Naglot
Updated on 14-Nov-2024 11:03:37

1K+ Views

As we know, both Java and JavaScript are programming languages and are used in application development. But there are significant differences between the languages, which we will discuss below. Java Java is a high-level language that is also a platform-independent language. It is mainly used in the development of web applications, mobile applications, games, etc. Java is a statically typed language, which means that the code must be checked for errors before it runs. JavaScript whereas JavaScript is a dynamically typed language, which means that the code is checked for errors while it runs. JavaScript is a client-server-side language, which ... Read More

How to make your code faster using JavaScript Sets?

Arnab Chakraborty
Updated on 23-Aug-2022 07:20:29

1K+ Views

While writing code, we always try to make our code easier to read, less complex, more efficient, and smaller in size. For that, we follow several methodologies which make our code efficient. In this article, we shall focus on some techniques based on Javascript sets to perform certain array-like or collection-based applications which will run faster and the code will also be concise. Let us focus few use cases. How sets are different than arrays and the benefits of using sets over an array Arrays are indexed collections where each element is associated with a specific index. On the other ... Read More

Javascript search for an object key in a set

Disha Verma
Updated on 13-Mar-2025 13:09:45

422 Views

In JavaScript, to search for an object key in a Set, you need to understand how Sets store values and how objects behave in JavaScript. JavaScript Sets are useful objects that store unique values, making them excellent for handling distinct data. In this article, we'll explore different ways to search for an object key in a Set. JavaScript Set A Set in JavaScript is a collection of unique values. Values like numbers and strings can be compared directly, but objects are stored by reference. This means that even if two objects have the same properties, they are still seen ... Read More

Difference between HashMap and HashSet in Java.

Nitin Sharma
Updated on 15-Sep-2023 01:07:13

26K+ Views

HashMap and HashSet both are one of the most important classes of Java Collection framework.Following are the important differences between HashMap and HashSet.Sr. No.KeyHashMapHashSet1ImplementationHashmap is the implementation of Map interface.Hashset on other hand is the implementation of set interface.2Internal implementationHashmap internally do not implements hashset or any set for its implementation.Hashset internally uses Hashmap for its implementation.3Storage of elementsHashMap Stores elements in form of key-value pair i.e each element has its corresponding key which is required for its retrieval during iteration.HashSet stores only objects no such key value pairs maintained.4Method to add elementPut method of hash map is used to ... Read More

How to know whether a value is searched in Javascript sets?

Arnab Chakraborty
Updated on 23-Aug-2022 06:54:47

172 Views

In javascript, we may use some sets to hold a few objects. Sometimes we want to check whether an element is present inside a set or not. In this article, we will see different techniques to check whether an element is inside a given set or not.p> A trivial method using for loop At first, we can search for an element by manually picking an element and checking whether it is the same as the key element or not. If so then simply return true, otherwise after completing all elements return false. Examples HTML ... Read More

Difference between Definition and Declaration in Java.

Nitin Sharma
Updated on 18-Sep-2019 12:14:17

3K+ Views

For the difference between definition and declaration, one should consider their literal meaning first which includes Declare means to announce or proclaim while Define means to describe some entity.The following are the important differences between the Definition and the Declaration.Sr. No.KeyDeclarationDefinition1ConceptThe concept of declaration includes informing the compiler about properties of the variable such as its name, type of value it holds and the initial value if any it takes.While the definition is basically the actual implementation and memory location of function and about memory for the variable is allocated during the definition of the variable.2Exception in CBoth declaration and ... Read More

Advertisements