
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 6710 Articles for Javascript

9K+ Views
We can set a countdown timer in JavaScript using the setInterval() method. This method continuously calls a function or executes a code snippet with a fixed time delay between every call. The setInterval() method calls a function at described intervals in milliseconds. It continues calling the function until the clearInterval() is called, or the window is closed. SyntaxFollowing is the syntax of this method − setInterval(function, milliseconds); The setInterval method accepts two parameter functions and milliseconds. function − A function containing a block of code designed to perform a particular task. milliseconds − it is the time interval ... Read More

331 Views
You can't break from each method. It copies the native forEach method's behavior and the native forEach doesn't provide to escape the loop (other than throwing an exception).You can use other functions like −_.find: it breaks out of the loop when the element is found. For example,_.find([1, 2, 3, 4], (element) => { // Check your condition here if (element === 2) { return true; } // Do what you want with the elements here // ... });Throw an exception from each. For example,try { _([1, 2, 3, 4]).each((element) => { // Check your condition here if (element === 2) { throw new Error(); } // Do what you want with the elements here // ... }) } catch (e) { // Do nothing. }

1K+ Views
The preload attribute specifies how the author thinks about the media file should be loaded when the page loads. The preload attributes allow the author to provide hints to the browser about how much time should take to load a page, it will lead to the best user experience. Preload also tells the browser about critical resources that you want to load as soon as possible. This is especially useful for resources that are not easily appreciable, such as fonts included in stylesheets, background images, or resources loaded from a script. Using preload helps here because the images start loading ... Read More

5K+ Views
It is believed that there can be any performance-based differences when the variables are declared inside or outside the loops, but there will be no difference. As there is flexibility in any programming language to declare the variables as and when required which will be easy for the users to read and understand accordingly. So, in JavaScript too the variables can be declared inside or outside the loop as per the users ease anywhere in the function body. And even variable declarations are not commands that are executed at the run-time. If the variable is declared outside the loop, then ... Read More

10K+ Views
In this article, we will learn about various methods to get the size of a JSON object in JavaScript. Getting the size of the object in JavaScript is same as the counting the total number of keys of an object. In general, we can get the size or number of keys of a JSON object in JavaScript by using two methods. Using object.keys() The object.keys() method returns an array of the given object of its countable properties name with the same order as we get as a normal loop. Following is the syntax of this method − Object.keys(name_of_object).length; ... Read More

1K+ Views
HTML is a mark-up language used to create the useful elements of a webpage. The DOM which means Document Object Model is used to manipulate the HTML Document. In DOM, all the elements are defined as objects. The styling in the HTML document can be done by using CSS. In here, JavaScript is being used to manipulate them. The ways in which the class can be added to a class to the DOM elements are described below. Using className If the element has a class already, then it will just add another class to it if not the element gets ... Read More

935 Views
In JavaScript, there are various approaches to add a class to an element. We can use the .className attribute or the .add() method to add a class name to the specific element. The class attribute can be used in CSS to perform some tasks for the elements with the parallel class name. Using the className Property We can use this property to add a class to an HTML element without restoring its existing class. This property can be used to execute the value of the class attribute of an element. If a class is already declared for an element, ... Read More

367 Views
The JavaScript Map is the data structure that helps us to store the data in the form of pairs. The pairs consist of a unique key and value mapped to the key. It helps to prevent duplicity. The JavaScript Object also follows the same concept as that of a map i.e. key−value pairs for storing data. But there are slight differences that make the map a better performer in certain situations Let us look into these differences between a Map and an Object further in this article. Map vs Object Following are the major differences between Map and Object ... Read More

364 Views
Sentry is a complete javascript debugging and monitoring tool package that allows you to track your production code. Some of the features of sentry −Record environment and usage details to recreate and fix bugsSee the error and stack trace previously only visible in user's debug console.Apply source maps automatically to convert minified, compiled, or transpiled code back to its original form.Mobile app reporting support.

5K+ Views
In this article, we are going to discuss how to detect the version of a browser using JavaScript. These days, most browsers are JavaScript−enabled. But still, there are some browsers that don’t support JavaScript; or, some versions of some browsers don’t support certain features of JavaScript. Therefore, in certain instances, there is a need to know the details of the client’s web browser so that the applications can deliver appropriate content. Detecting the Version of a Browser You can detect the details of the current browser using navigator.appName and navigator.appVersion properties. To detect the version of the browser in the ... Read More