1,863 questions
Best practices
0
votes
7
replies
223
views
Is fixing child.prototype.constructor necessary in ES5 if we solely rely on [[Prototype]] check methods like Object.getPrototypeOf()?
When implementing the parasitic combination inheritance pattern in ES5, almost every resource (including Nicholas Zakas' book) insists on fixing the constructor property like this:
function ...
Score of 2
1 answer
136 views
Web Components in Scheme interpreter in JavaScript?
I have a Scheme interpreter written in JavaScript called LIPS, and I have a define-class macro which is using the ES5 prototype system. But I have a problem in creating super().
I'm trying to create a ...
Score of 0
3 answers
148 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 ...
Score of 0
1 answer
63 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 ...
Score of 0
0 answers
109 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 ...
Score of 0
1 answer
145 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 ...
Score of 1
1 answer
223 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 ...
Score of 1
0 answers
154 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 ...
Score of 1
1 answer
73 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 ...
Score of 1
1 answer
154 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:
...
Score of 0
0 answers
35 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 ...
Score of 0
1 answer
144 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'...
Score of 1
0 answers
173 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 ...
Score of 0
2 answers
283 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 ...
Score of 0
2 answers
83 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 (...