Category "ecmascript-6"

What's the difference between using "let" and "var"?

ECMAScript 6 introduced the let statement. I've heard that it's described as a local variable, but I'm still not quite sure how it behaves differently than the

(JavaScript) Best was to check for multiple conditions and end execution as soon as one returns false?

I am currently working on a duty rota App. I need to calculate which employee can work on every particular day of the month. This must also be updated "on the f

Produce CSV from JSON object

I have a JSON Object like so that I am trying to produce a CSV from { "football": { "count": 2109, "emailed": 0, "optin": 2109,

How to import a JSON5 file (as one can regular JSON) in Typescript?

I would like to import a JSON5 file into a Javascript object in the same way [one can import a JSON file](import config from '../config.json'). Shows this mess

How to pass document variable to ES6 Module during Jasmine testing

I want to test if a function in a module generated something in document but I am having trouble defining the document variable. I have simulated it jsdom but I

IntersectionObserver does not work on small screens for long sections JS

This script issues the active class for the active section. Recently noticed that it stops working on small screens. Even in the developer's console in chrome,

Generate array with values A1, A2, A3, B1, B2, B3... etc?

I'm trying to generate an array of objects where it outputs an array looking like this: [ { _id: 2, label: 'A1' }, { _id: 3,

What was the motivation for introducing a separate microtask queue which the event loop prioritises over the task queue?

My understanding of how asynchronous tasks are scheduled in JS Please do correct me if I'm wrong about anything: The JS runtime engine agents are driven by an e

Change Button Text in loop using React

Is it possible to change button text that is created using array. If it is possible, what should I do with the onClick function in the button. Here is the sampl

How does Angular differentiate between refresh event and close browser/close tab event?

How does Angular differentiate between refresh event and close browser/close tab event? I tried to listen to the event beforeunload, but I found that this event

How to use template literals of ES6 script

I have been trying to solve a template literal question on hackerrank. It works fine on my local IDE but giving error on Hackerrank IDE. Heres the code two add

React native webview crashing on Android when attach/selecting a file

I am using react-native-webview v.11 and it works all great unless you try to attach a file using the webview and the Android just crash. I have been looking ev

Webpack in ES6 create an empty bundle

I am trying to use webpack in ES6 but there is something wrong, the bundle is created but it seems to contain nothing. src/index.js console.log("inside"); expor

Mixed named and unnamed parameters in JavaScript?

For a function with an intuitive first argument (e.g. a find semantic) I'd like to provide a way to write a function call without argument names while more comp

What is the difference between Array.from(Object) and [...Object]? [duplicate]

There are these two ES6-methods of creating an array from an array-like or iterable object: Array.from(): let arr = Array.from(Object); Spre

Keep hitting an error when trying to use export/import in JavaScript using Atom

I'm trying to write an array in one .js that can be exported to another, but when I try to import it into the other.js Atom keeps throwing me back the following

How to expose a class to the global scope with esbuild?

Update user @TKoL suggested defining a property in the window object. This produces the result I wanted to achieve, although I do not know if it is the correct

local storage is not persistent in react app

I am creating a react app which is using local storage. I am saving and array of objects to local storage. when I try to save to local storage the data is savin

How to reduce size on QR code scanner, customize QR code scanner

How can I reduce the size of my QR Code scanner. When I am trying to apply style prop, its not working In below code my scanner is working but it is coming on f

What is the temporal dead zone?

I've heard that accessing let and const values before they are initialized can cause a ReferenceError because of something called the temporal dead zone. What