Ayush Gupta has Published 527 Articles

Explain the event flow process in Javascript

Ayush Gupta

Ayush Gupta

Updated on 19-Sep-2019 08:21:34

849 Views

In the JavaScript, Event Flow process is completed by three concepts −Event Target − The actual DOM object on which the event occured.Event Bubbling − Explained belowEvent Capturing − Explained belowEvent bubbling is the order in which event handlers are called when one element is nested inside a second element, ... Read More

Name some of the string methods in javascript?

Ayush Gupta

Ayush Gupta

Updated on 19-Sep-2019 07:37:38

320 Views

The String object lets you work with a series of characters; it wraps Javascript's string primitive data type with a number of helper methods. As JavaScript automatically converts between string primitives and String objects, you can call any of the helper methods of the String object on a string primitive.Following ... Read More

Write the usage of split() method in javascript?

Ayush Gupta

Ayush Gupta

Updated on 19-Sep-2019 07:33:18

274 Views

The split([separator, [limit]]) method splits a String object into an array of strings by separating the string into substrings, using a specified separator string to determine where to make each split.Example usage of split methodlet a = "hello, hi, bonjour, namaste"; let greetings = a.split(', '); console.log(greetings)Output[ 'hello', 'hi', 'bonjour', ... Read More

How to convert a string to camel case in JavaScript?

Ayush Gupta

Ayush Gupta

Updated on 19-Sep-2019 07:15:02

1K+ Views

Camel case is the practice of writing phrases such that each word or abbreviation in the middle of the phrase begins with a capital letter, with no intervening spaces or punctuation. For example, Concurrent hash maps in camel case would be written as −ConcurrentHashMapsWe can implement a method to accept ... Read More

Why is using “for…in” with array iteration a bad idea in javascript?

Ayush Gupta

Ayush Gupta

Updated on 19-Sep-2019 06:57:52

178 Views

Using for..in loops in JavaScript with array iteration is a bad idea because of the following behavior −Using normal iteration loops −Examplelet arr = [] arr[4] = 5 for (let i = 0; i < arr.length; i ++) {    console.log(arr[i]) }Outputundefined undefined undefined undefined 5If we had iterated over ... Read More

Class Keyword in JavaScript

Ayush Gupta

Ayush Gupta

Updated on 18-Sep-2019 13:14:06

261 Views

JavaScript classes, introduced in ES6, are syntactical sugar over JavaScript prototype-based inheritance. Classes are in fact "special functions". You can define classes in JavaScript using the class keyword using the following syntax −class Person {    // Constructor for this class    constructor(name) {       this.name = name; ... Read More

JavaScript RegExp W Metacharacter

Ayush Gupta

Ayush Gupta

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

264 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 falseRead More

JavaScript RegExp s Metacharacter

Ayush Gupta

Ayush Gupta

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

151 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

483 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

184 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

Advertisements