Ayush Gupta has Published 541 Articles

C++ program to find two numbers with sum and product both same as N

Ayush Gupta

Ayush Gupta

Updated on 03-Oct-2019 11:00:48

472 Views

In this tutorial, we will be discussing a program to find two numbers (say ‘a’ and ‘b’) such that botha+b = N and a*b = N are satisfied.Eliminating ‘a’ from both the equations, we get a quadratic equation in ‘b’ and ‘N’ i.eb2 - bN + N = 0This equation ... Read More

How to free up the memory in JavaScript?

Ayush Gupta

Ayush Gupta

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

1K+ 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

454 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

564 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

179 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

177 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

95 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

136 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

181 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