Ayush Gupta has Published 551 Articles

JavaScript RegExp s Metacharacter

Ayush Gupta

Ayush Gupta

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

79 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 trueRead More

Javascript search for an object key in a set

Ayush Gupta

Ayush Gupta

Updated on 18-Sep-2019 12:16:54

302 Views

The Set class in JavaScript provides a has method to search elements in a given set object. In case you want to search for a object in a set, you need to provide the reference to that object. Identical objects with different memory addresses are not considered equal. This method ... Read More

How to remove all the elements from a set in javascript?

Ayush Gupta

Ayush Gupta

Updated on 18-Sep-2019 12:03:47

324 Views

The Set class in JavaScript provides a clear method to remove all elements from a given set object. This method can be used as follows −Examplelet mySet = new Set(); mySet.add(1); mySet.add(2); mySet.add(1); mySet.add(3); mySet.add("a"); console.log(mySet) mySet.clear(); console.log(mySet)OutputSet { 1, 2, 3, 'a' } Set { }You can also individually ... Read More

Ways to create a Set in JavaScript?

Ayush Gupta

Ayush Gupta

Updated on 18-Sep-2019 12:01:15

68 Views

A set is an abstract data type that can store certain values, without any particular order, and no repeated values. It is a computer implementation of the mathematical concept of a finite set. Unlike most other collection types, rather than retrieving a specific element from a set, one typically tests ... Read More

What are javascript sets?

Ayush Gupta

Ayush Gupta

Updated on 18-Sep-2019 11:57:00

102 Views

A set is an abstract data type that can store certain values, without any particular order, and no repeated values. It is a computer implementation of the mathematical concept of a finite set. Unlike most other collection types, rather than retrieving a specific element from a set, one typically tests ... Read More

What is the use of OBJECT.assign() in javascript?

Ayush Gupta

Ayush Gupta

Updated on 17-Sep-2019 08:55:08

197 Views

The Object.assign() method is used to copy the values of all of the object's own properties(enumerable only) from one or more source objects to a target object. It will return the target object.Exampleconst targetObj = { a: 1, b: 2 }; const sourceObj = { b: 4, c: 5 }; ... Read More

Eradicating Memory Leaks in Javascript

Ayush Gupta

Ayush Gupta

Updated on 17-Sep-2019 08:15:58

97 Views

The main cause for leaks in garbage collected languages are unwanted references. To understand memory leaks, let us see how the memory freeing(garbage collection) works.Mark-and-sweep algorithm −This algorithm reduces the definition of "an object is no longer needed" to "an object is unreachable". This algorithm assumes the knowledge of a ... Read More

How to avoid circular reference in OOP Javascript?

Ayush Gupta

Ayush Gupta

Updated on 17-Sep-2019 08:05:54

360 Views

A circular reference occurs if two separate objects pass references to each other.In older browsers circular references were a cause of memory leaks. With improvements in Garbage collection algorithms, which can now handle cycles and cyclic dependencies fine, this is no longer an issue.However, from a pure design point of ... Read More

Why circular reference is bad in javascript?

Ayush Gupta

Ayush Gupta

Updated on 17-Sep-2019 08:02:47

1K+ Views

A circular reference occurs if two separate objects pass references to each other.In older browsers circular references were a cause of memory leaks. With improvements in Garbage collection algorithms, which can now handle cycles and cyclic dependencies fine, this is no longer an issue.However, from a pure design point of ... Read More

Differences between web-garden and a web-farm in Javascript

Ayush Gupta

Ayush Gupta

Updated on 16-Sep-2019 08:52:25

332 Views

Web Garden is the web hosting system which comprises of multiple “processes”. This means that we have a single server on which we run multiple processes. This type of hosting provides logical scalability to our web applications.Web Farm is the web hosting system which comprises of multiple “computers”. This is ... Read More

Advertisements