Ayush Gupta has Published 530 Articles

JavaScript RegExp s Metacharacter

Ayush Gupta

Ayush Gupta

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

132 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

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

Ayush Gupta

Ayush Gupta

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

447 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

145 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

196 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

275 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

177 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

483 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

414 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

Convert the string of any base to integer in JavaScript

Ayush Gupta

Ayush Gupta

Updated on 16-Sep-2019 08:19:08

151 Views

The parseInt function available in JavaScript has the following signature −parseInt(string, radix);Where, the paramters are the following −String − The value to parse. If this argument is not a string, then it is converted to one using the ToString method. Leading whitespace in this argument is ignored.Radix − An integer ... Read More

Advertisements