Ayush Gupta has Published 530 Articles

C++ program to find union and intersection of two unsorted arrays

Ayush Gupta

Ayush Gupta

Updated on 03-Oct-2019 11:14:47

2K+ Views

In this article, we will be discussing a program to find the union and intersection of two given unsorted arrays.Let us denote the two arrays with ‘A’ and ‘B’. Then union of those arrays is denoted by A ∪ B which is basically an array of all the elements in ... Read More

How to free up the memory in JavaScript?

Ayush Gupta

Ayush Gupta

Updated on 19-Sep-2019 08:31:03

2K+ Views

Regardless of the programming language, memory life cycle is pretty much always the same −Allocate the memory you needUse the allocated memory (read, write)Release the allocated memory when it is not needed anymoreThe second part is explicit in all languages. Use of allocated memory needs to be done by the ... Read More

How to allocate memory in Javascript?

Ayush Gupta

Ayush Gupta

Updated on 19-Sep-2019 08:28:25

529 Views

Regardless of the programming language, memory life cycle is pretty much always the same −Allocate the memory you needUse the allocated memory (read, write)Release the allocated memory when it is not needed anymoreThe second part is explicit in all languages. Use of allocated memory needs to be done by the ... Read More

Explain the event flow process in Javascript

Ayush Gupta

Ayush Gupta

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

785 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

285 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

244 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

147 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

229 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

243 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

Advertisements