Ayush Gupta has Published 530 Articles

What Is a JavaScript Framework?

Ayush Gupta

Ayush Gupta

Updated on 02-Dec-2019 05:57:56

1K+ Views

JS frameworks are JavaScript code libraries that have pre-written code to use for routine programming features and tasks. It is literally a framework to build websites or web applications around.For example, in plain JS, you have to manually update the DOM using DOM APIs for setting styles updating content, etc.JS ... Read More

What are the differences between clientHeight() and offsetHeight() in javascript?

Ayush Gupta

Ayush Gupta

Updated on 02-Dec-2019 05:57:09

321 Views

You can use 2 properties, clientHeight and offsetHeight to get the height of the div.clientHeight includes padding of the div.offsetHeight includes padding, scrollBar, and borders of the div.ExampleFor example, if you have the following HTML −You can get the height using −const height = document.querySelector('#myDiv').offsetHeight console.log(height)OutputThis will give the output ... Read More

How to create a new object with only a subset of properties using vanilla Javascript

Ayush Gupta

Ayush Gupta

Updated on 02-Dec-2019 05:54:32

257 Views

To get a subset of object's properties and create a new object out of those properties, use object destructuring and property shorthand. For example, You have the following object −Exampleconst person = {    name: 'John',    age: 40,    city: 'LA',    school: 'High School' }And you only want ... Read More

How to get a subset of a javascript object's properties?

Ayush Gupta

Ayush Gupta

Updated on 02-Dec-2019 05:53:16

303 Views

To get a subset of object's properties and create a new object out of those properties, use object destructuring and property shorthand. For example, You have the following object −Exampleconst person = {    name: 'John',    age: 40,    city: 'LA',    school: 'High School' }And you only want ... Read More

What blocks Ruby, Python to get Javascript V8 speed?

Ayush Gupta

Ayush Gupta

Updated on 02-Dec-2019 05:51:42

127 Views

Nothing. They can get to V8 speed if proper investments are made in optimizing those language engines as are made for JS by Google in the V8 project.This is all really a matter of how much push is provided to the language by sponsoring organizations to further the development and ... Read More

Converting strings to numbers with vanilla JavaScript

Ayush Gupta

Ayush Gupta

Updated on 02-Dec-2019 05:41:54

197 Views

The parseInt function available in JavaScript has the following signature −SyntaxparseInt(string, radix);Where the parameters 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

Jasmine JavaScript Testing - toBe vs toEqual

Ayush Gupta

Ayush Gupta

Updated on 02-Dec-2019 05:39:23

796 Views

Arrays can be compared in 2 ways −They refer to the same array object in memory.They may refer to different objects but their contents are all equal.ExampleFor case 1, jasmine provides the toBe method. This checks for reference. For example, describe("Array Equality", () => {    it("should check for array ... Read More

If a DOM Element is removed, are its listeners also removed from memory in javascript?

Ayush Gupta

Ayush Gupta

Updated on 02-Dec-2019 05:35:14

3K+ Views

In modern browsers, if a DOM Element is removed, its listeners are also removed from memory in javascript.Note that this will happen ONLY if the element is reference-free. Or in other words, it doesn't have any reference and can be garbage collected. Only then its event listeners will be removed ... Read More

What is the difference between 'throw new Error' and 'throw someObject' in javascript?

Ayush Gupta

Ayush Gupta

Updated on 02-Dec-2019 05:34:13

539 Views

The difference between 'throw new Error' and 'throw someObject' in javascript is that throw new Error wraps the error passed to it in the following format −{    name: 'Error',    message: 'Whatever you pass in the constructor' }The throw someObject will throw the object as is and will not ... Read More

What are the differences between Deferreds, Promises and Futures in javascript?

Ayush Gupta

Ayush Gupta

Updated on 02-Dec-2019 05:31:52

1K+ Views

Future is an old term that is same as promise.A promise represents a value that is not yet known. This can better be understood as a proxy for a value not necessarily known when the promise is created.A deferred represents work that is not yet finished. A deferred (which generally ... Read More

Advertisements