Vineeth.mariserla has Published 278 Answers

What is the importance of '+' operator in type conversion in JavaScript?

vineeth.mariserla

vineeth.mariserla

Updated on 30-Jun-2020 14:58:02

'+' operator has many uses including addition, concatenation, and most importantly type conversion. Generally, we use '+' operator for addition and at some times for concatenation. It also has a lot of use in type conversion. It is very easy to convert a string into a number.ExampleLive Demo<html> <body> <script> ... Read More

What is the relation between 'null' and '0' in JavaScript?

vineeth.mariserla

vineeth.mariserla

Updated on 30-Jun-2020 14:36:27

There is a lot of curiosity arises when we are dealing with false values and it is even more especially when dealing with "null" and "0" because of their properties. When we try to compare "null" and "0", we will come across typical scenarios. For greater than(>), less than(<) and ... Read More

How to shallow copy the objects in JavaScript?

vineeth.mariserla

vineeth.mariserla

Updated on 30-Jun-2020 14:08:12

Underscore.js, a library of javascript, has introduced a method called _.extend() to shallow copy the objects in javascript. This method copy all of the properties in the source objects over to the destination object, and return the destination object. Here the reference is used to copy but not the duplication. syntax_.extend(object*);It accepts objects and shallow ... Read More

How to get the values of an object in JavaScript?

vineeth.mariserla

vineeth.mariserla

Updated on 30-Jun-2020 13:46:36

There are some methods such as Object.values() to get the values of an object. But through those methods, the process to find out the values is lengthy. To alleviate this, Underscore.js a library of javascript has provided a method called _.values(). This method requires no for loop to execute the ... Read More

How to invert an object in JavaScript?

vineeth.mariserla

vineeth.mariserla

Updated on 30-Jun-2020 13:38:32

Inverting an object is one of the difficult tasks until underscore.js, a javascript framework, came into light. It has many functions in which _.invert() is one of them. This method actually inverts the key/value pairs. For suppose let an object has a key/value like name/Kiran. Then after inverting the object using ... Read More

How to get the first n values of an array in JavaScript?

vineeth.mariserla

vineeth.mariserla

Updated on 30-Jun-2020 13:18:36

To get the first n elements of an array we can use many logical methods, but underscore.js a library of javascript has provided a function called _.first() to get the first n elements of javascript. It is a widely used method to deal with arrays.syntax_.first(array, n);it takes an array and a number ... Read More

How to find out all elements that matches a specific condition in JavaScript?

vineeth.mariserla

vineeth.mariserla

Updated on 30-Jun-2020 12:37:11

Javascript has many frameworks in which underscore.js is one of them. It has provided many functions in which _.where() is a function used to find elements based on a specific condition.This method will display the elements based on whether they passed the condition or not. For suppose if we passed a condition ... Read More

How to find the common elements between two or more arrays in JavaScript?

vineeth.mariserla

vineeth.mariserla

Updated on 30-Jun-2020 11:26:20

If there are only two arrays then by using logical methods, it is possible to find the common elements. But if there are more arrays then it is difficult to find the common elements. So to make the process as easy as possible, the _.intersection() method comes into the picture. It ... Read More

How to remove the 0th indexed element in an array and return the rest of the elements in JavaScript?

vineeth.mariserla

vineeth.mariserla

Updated on 30-Jun-2020 10:10:48

The _.rest() is used to return the rest of the elements except the zeroth indexed element. It belongs to underscore.js, a library of javascript. It takes two parameters. One is an array and the other is an index. The second parameter is used to start the search from the given indexed ... Read More

How to remove event handlers in JavaScript?

vineeth.mariserla

vineeth.mariserla

Updated on 30-Jun-2020 09:21:27

Javascript provides removeEventListener() method to remove event handlers. An event is handled through addEvenetListener() method. The removeEventListener() method removes event handlers that have been attached with that addEventListener() method.ExampleLive Demo<html> <body>    <h3 id="add">Hover me </h3>    <p id="remove"> </p>    <h3>Click this button to stop hovering effect </h3>    <input type ="button" ... Read More

Previous 1 ... 3 4 5 6 7 8 9 ... 28 Next
Advertisements