1,862 questions
0
votes
3
answers
141
views
How to replace multiple regex matches in a JSON object
Given a JSON object which contains tags identified by {{, I need to find all matches in the payload and replace them. The following code works, but only returns the 1st match, and if I turn on the gim ...
0
votes
1
answer
52
views
Nashorn: Execute script with anonymous root-level function and subfunctions
I'm attempting to put together a basic test framework for a number of JS scripts that I've been provided. These all run on nashorn (JDK 11) without issue in their original habitat. I'm attempting to ...
0
votes
0
answers
89
views
Preserving type parameters of a constructor when replacing the instance type
I'm coding a type-safe class system using ES5 and JSDoc.
At the most basic level, the problem boils down to adding a property to the constructor's returned instance type, while preserving the type ...
0
votes
1
answer
127
views
How to replace code before transpiling TypeScript code using Rollup. (How to transpile TypeScript code with Private Class Fields to ES5.)
I wont to do
I want to transpile TypeScript code with Private Class Fields to ES5 like when using TypeScript's private identifier.
(I give up one or the other, it will be resolved soon. But I don't ...
1
vote
1
answer
215
views
How do I transpile Angular 17 ES6 app to ES5 for Android 10 devices
Working on a web app for a specialized device that runs Android 10 (Webview uses Chromium <80). When I try to serve the app and test on the Android device, I get errors for using optional chaining ...
1
vote
0
answers
142
views
React Hooks Behavior: Difference When Using variables and states in useCallback before their Definition (ES5)
I have a doubt regarding, how hooks like useCallback() work when the variables, arrow functions, and states used in it and its dependency, are declared before and after the useCallback().
Note: The ...
1
vote
1
answer
68
views
Simulating an auxiliary constructor in ECMAScript 5
I was going through "JavaScript the definitive guide" and I encountered this auxiliary constructor (below their Set definition):
// Definition of Set, taken from chapter 9.6.1
function ...
1
vote
0
answers
132
views
How can Babel transpile a Node.js module polyfill (e.g. buffer) to ES5?
I would like to transpile JS code which uses the Node 'buffer' to pure ES5 so it can run on Duktape (with Webpack and Babel).
The code has been simplified in a test.js, which uses buffer and console:
...
0
votes
0
answers
33
views
Consecutive day counter in ES5
I am trying to write logic in ES5 (in BIRT) to assess if an employee has worked 10 days in a row. I have extracted the start dates but can't seem to get the logic to work as intended. If an employee ...
0
votes
1
answer
129
views
What does the "ECMA Script" project setting in TMS WEB Core do?
In the project settings, you're able to set "ECMA Script" between nothing, "ECMA Script 5" and "ECMA Script 6".
But I'm really confused as to what this actually does. I'...
1
vote
0
answers
149
views
How do I support old browsers in my create-react-app project?
I have an app that I built using create react app. I just found out that it needs to support a very old browser (chrome 37). I was under the impression that by default create react app uses babel to ...
0
votes
2
answers
275
views
Get object's class name in ES5/ES5.1
In ES6 there is .constructor.name which can be used on any object to get its class name.
Is there something in ES5 that can do that?
(Note: Before commenters mention to upgrade the browser, etc., this ...
0
votes
2
answers
82
views
How to optimize search of unasked questions?
Currently I have the following code -
var questions = ['1', '2', '3', '4', ..., 'n'];
var qAsked = []; // array of indexes of already asked questions
// the code below is executed multiple times
if (...
0
votes
0
answers
57
views
ES6 Class compilation to ES5 function constructor
I noticed something while playing with Typescript's compiler options. (Typescript is irrelevant here, I'm just using it as a compiler much like babel)
So, I have this code in .ts file
(function () ...
1
vote
1
answer
173
views
Code.org -- Searching in a database for the proper day and then adding it into a list
I am working on a project for school and am almost finished with it. I need code.org to search through my database for Habits that occur on the day set. (Days of the week) then be put into a list and ...