Category "ecmascript-6"

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

Why does Javascript `iterator.next()` return an object?

Help! I'm learning to love Javascript after programming in C# for quite a while but I'm stuck learning to love the iterable protocol! Why did Javascript adopt

Restructuring the object using different name [Object manipulation]

I have a use case where I have to restructure the object. Initial I have this object { name: 'Tommy Kerar', mandatoryRequirements : [{ name:

How to render conditional with classNames with Reactjs

I am trying to use classNames to replace the conditional below in one line. My problem is that i am not sure what is the right way to write the code because of

How to access the class itself from within a class without using its name [duplicate]

Is it possible to access the class itself inside of a classes function: class MyClass { static get myFunction() { return "foo"; } const

handle multiple checkboxes and complex data structure (reactjs)

Since I am pretty new to React and also not a huge expert on JS especially ES6, I wonder how to make my code (that works) prettier and refactor it. I want to h

Average with the Reduce Method in JavaScript

recently I tried to calculate Average with the Reduce Method In JavaScript​ here is may code var arr = [129, 139, 155, 176]; var result = arr.reduce(fu

changing video source in useEffect based on language change

I'm trying to play different videos on language change. however the same video always plays, useEffect(() => { console.log("language changed: ", i18n.langua

is it possible to run a rollup plugin without an input file (in a multi bundle instance)?

I have a situation where I am bundling multiple files via rollup cli an example of this is available in documentation. I export an array of bundles like so: e

How to block cookies until consent is given with Javascript [duplicate]

My company has given me the task of creating a cookie consent package that can be included in any of our different Javascript single-page appl

Is destructing assigning in JavaScript shallow or deep copy?

I'm confused by the destructing assigning in JavaScript about shallow and deep copy. For example, const obj = {key:{}, value:{}} let {key} = obj key = {msg: 'he