Found 8591 Articles for Front End Technology

Javascript Map vs Object — What and when?

Aman Kumar
Updated on 19-Dec-2022 11:26:09

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

What is the use of sentry in javascript?

Ayush Gupta
Updated on 02-Dec-2019 06:25:48

365 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.

How can you detect the version of a browser using Javascript?

Aman Kumar
Updated on 19-Dec-2022 11:16:05

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

Is it possible to change values of the array when doing foreach() in javascript?

Abdul Rawoof
Updated on 02-Sep-2022 11:38:10

6K+ Views

Array is a data type which can store multiple elements of similar data types. For example, array is declared as integer data type then it stores one or more elements of the integer data type. In arrays the element can be manipulated when they are in a loop by using any of the mathematical operations or so. For example, if the array elements are numbers, then the numbers can be multiplied by a fixed number or can be added or subtracted also. The change in the array elements can be done by using a user defined program and the result ... Read More

Proper way to catch exception from JSON.parse

Ayush Gupta
Updated on 02-Dec-2019 06:17:05

4K+ Views

The best way to catch invalid JSON parsing errors is to put the calls to JSON.parse() to a try/catch block.Examplefunction parseJSONSafely(str) {    try {       return JSON.parse(str);    }    catch (e) {       console.err(e);       // Return a default object, or null based on use case.       return {}    } }

Difference between application/x-javascript and text/javascript content types?

Ayush Gupta
Updated on 02-Dec-2019 06:07:38

1K+ Views

The text/javascript content type is obsolete. This was used in the early days of Html.application/x-javascript was an experimental content type(hence the x-). You should not be using this in your application.The correct content type to use in browsers is application/javascript. This helps browsers accept the content as js code.

What is the replacement of lodash pluck() method?

Ayush Gupta
Updated on 02-Dec-2019 06:06:54

1K+ Views

Pluck has been removed from lodash 4. This is because it did the same thing as a map.As a replacement, you can use the map function in the following way −Exampleimport _ from 'lodash' const objects = [{ 'a': 1 }, { 'a': 2 }]; console.log(_.map(objects, 'a'))OutputThis will give the output −[1, 2]

Where is _.pluck() in lodash version 4?

Ayush Gupta
Updated on 02-Dec-2019 06:06:00

432 Views

Pluck has been removed from lodash 4. This is because it did the same thing as a map.As a replacement, you can use the map function in the following way −Exampleimport _ from 'lodash' const objects = [{ 'a': 1 }, { 'a': 2 }]; console.log(_.map(objects, 'a'))This will give the output −Output[1, 2]

Why doesn't JavaScript support multithreading?

Ayush Gupta
Updated on 02-Dec-2019 06:04:38

527 Views

JavaScript used to be single-threaded. It runs using what is called an event loop.The Event Loop has one simple job — to monitor the Call Stack and the Callback Queue. If the Call Stack is empty, it will take the first event from the queue and will push it to the Call Stack, which effectively runs it.JS in browsers doesn't support multithreading in the event loop as it is not needed for 99.999% of the websites. The event loop handles everything seamlessly.For the remaining apps, devs can use web workers. Web Workers are a simple means for web content to ... Read More

How to deserialize a JSON into Javascript object?

Aman Kumar
Updated on 19-Dec-2022 11:12:58

3K+ Views

Serialization is the process of converting an object such that it is transferable over the network. In JavaScript usually we serialize an Object into the JSON (or JavaScript Object Notation) format. To reserialize a JSON into a JavaScript object, we need to use the method JSON.parse(). JavaScript object notation is used to exchange data to or from a web server of the rest full API. The data we get from a web server is always a string variable, in order to use it we need to parse it with JSON.parse() which will return a JavaScript object or array object. Following ... Read More

Advertisements