29,939 questions
-1
votes
0
answers
60
views
Object.defineProperty(exports, "__esModule", { value: true }); error Exports function exports is not defined
I am doing a TypeScript application example. I have my tsconfig.json file like this
"compilerOptions": {
"module":"commonjs",
"target":&...
-1
votes
1
answer
91
views
Why does `Array(3).map(x => 42)` return an empty array instead of `[42, 42, 42]` in JavaScript? [duplicate]
I was brushing up on Array for an implementation and I stumbled on this discovery, I expected the following code to give me an array filled with the number 42:
Array(3).map(x => 42)
But instead, ...
-1
votes
1
answer
73
views
`subClass extends baseClass` and not with `new` keyword in JavaScript [closed]
I'm new to JavaScript and I'm trying to achieve the logic I have commented in the constructor method of the base class
export default class Building {
constructor(sqft) {
this._sqft = sqft;
...
-4
votes
1
answer
111
views
Comparing for loops vs spread and concat for merging arrays in JavaScript — performance and best practices? [closed]
I'm learning JavaScript and practicing merging arrays. Here's one of the methods I wrote using two for loops:
const arr1 = [4, 5, 7, 9, 8];
const arr2 = [-1, -2, 0, 12];
const arr3 = [];
for (let i = ...
2
votes
1
answer
84
views
How does the JavaScript engine handle object identity and prototype inheritance between ShadowRealms and the main execution context?
I’m experimenting with the ECMAScript proposal for ShadowRealm and ran into some deeply unintuitive behavior around object identity, function bindings, and prototype inheritance across realms.
...
-4
votes
1
answer
129
views
HtmlService include() function breaks ES6 syntax in included files - template processing issue
I'm getting syntax errors when trying to modularize a Google Apps Script HTML project. The issue appears to be related to how the HTML service processes included files as templates rather than raw ...
-1
votes
2
answers
117
views
for await (let i of asyncIterable); 'i' is declared but its value is never read
I am using ixjs/AyncIterable (pull-model).
The simplest code I need to write at the end, to initiate the stream processing is:
for await (let i of asyncIterable);
But eslint does not like this:
'i' ...
3
votes
1
answer
95
views
Is it allowed in javascript to modify the handler after proxy has already been created?
I modify the handler object after proxy's creation, and obtain intended result. But nowhere in mdn document such pattern, can i rely on this pattern to work consistently across browser/in future?
...
0
votes
2
answers
191
views
Main chunk in Webpack references the wrong runtime chunk
In an existing web app written in Vue and PHP, we are trying to add a Micro Frontend using Module Federation.
After we configured the app, I found out that the watch command wasn't working correctly. ...
1
vote
2
answers
105
views
ES6 static class extends EventTarget
I wish to create a class which extends EventTarget, allowing addEventListener() and dispatchEvent() to be invoked on it.
Logically, my class wants to be a singleton; if a page accidentally ...
1
vote
0
answers
63
views
Inheriting constructor documentation in JSDoc with ES6 classes
I am writing documentation for some classes written using the ES6 class syntax. I have some classes which inherit their constructor from their parent class, as below:
/**
* @class
*/
class Parent {
...
2
votes
2
answers
123
views
Alternative to 'assert' in Node JS with strict mode
I have a Firebase Functions project that has "type" set to "module" in package.json so that I can use ES6 syntax. Some of the files import data from another json file with a line ...
-3
votes
1
answer
79
views
Why is the return not excuted? [closed]
my codes
console results
Here are my React codes. I know that if you write a function with a parenthesis, it will be called immediately (in this case, it will be called when elements render, I have ...
-1
votes
1
answer
297
views
How to import a component from published library and how to get component key
I'm working on a figma plugin where in I need to use the components
which are in published library assets. I know I should be using
figma.importComponentByKeyAsync() of figma plugin API, but I m not
...
0
votes
0
answers
128
views
How to solve Open Redirect vulnerability
In a webapp we are trying to solve an Open Redirect vulnerability.
The code is like this:
window.location.href = DOMPurify.sanitize(data.href);
Which apparently is vulnerable. One recommended solution ...