1,863 questions
0
votes
3
answers
135
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
50
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
84
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
125
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
139
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
66
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
131
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
125
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
140
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
269
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
73
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
56
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
171
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 ...
0
votes
1
answer
321
views
Use webpack and babel to convert ES6 to ES5 file javascript but it doesn't work
I use webpack and babel to convert ES6 to ES5 file javascript but it doesn't work. File code javascript contains many functions.
This is file webpack.config.cjs:
module: {
rules: [
...
0
votes
1
answer
115
views
Using Highcharts with IE 11 from ES5 folder but it crashes
I try to run Highcharts with IE11 but it crashes
I load Highcharts from ES5 folder as told in the documentation.
IE11 devtool console indicates that the Highcharts es5 code not seem to be valid ES5.
...
1
vote
0
answers
640
views
Vite Shopify CDN minification failed
I have tried this with two separate Vite setups for Shopify and I'm receiving the same problem. It's not liking the conversion to ES5, or it's not doing it at all and Shopify doesn't agree with it.
...
0
votes
1
answer
846
views
Transpile specific packages in node_modules to es5
I have(making) an Angular 12 (IE-compatible) project where a few of my dependencies in node_modules are non es5.
In my understanding tsc doesn't do anything with node_modules and just starts to ...
0
votes
0
answers
212
views
ES6 import all modules from a directory
We have a ES5 project where we used the import-modules library to import all files of a directory and execute there run()-function that I am now migrating to ES6.
...
import importModules from '...
0
votes
0
answers
346
views
Javascript ES5 method for interpolating string
I do not have access to string interpolation in our javascript engine and I need to create a solution for replacing all items in a string with previously defined variables. This needs to also work ...
0
votes
1
answer
38
views
Migration of a 'resourceManager' from ES5 to ES6
I am currently trying to migrate a project that uses a resourceManager.
I tried to sketch the functionality in the picture below. It basicly made it easier to use the different services I needed.
Now ...
0
votes
1
answer
327
views
JavaScript: duplicate property name and getter/setter an error in ES5?
JS noob here: If a getter/setter with a particular name is used that is the same as a property's name that takes on a value, and in code that is in strict mode, will an error occur in ES5? Ex (where ...
1
vote
4
answers
187
views
javascript : Sort a subset of an array (created by a filter)
I'm trying to sort only a subset of an array, the subset is a filtered version of that array, and I need the whole array (with the subset sorted ) as a result.
Here is the main array :
var data = [
{...
4
votes
0
answers
918
views
Next.js Type error: Type 'Set<any>' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher
I am getting the following error when compiling my Next.js app (with Typescript) with the "npm run build" command.
Type error: Type 'Set' can only be iterated through when using the '--...
4
votes
5
answers
280
views
How to batch group of array elements in reference to another array of group size?
How to batch group of array elements in reference to another array of group size ?
I tried below code.
Code:
var group_size = [1, 3, 5];
var elements = ['a','b','c','d','e','f','g','h','i','j','k','l']...
-2
votes
1
answer
84
views
Error as '`' (backquotes) not allowed in javascript (ecma5) [duplicate]
var now = new Date();
var year = now.getUTCFullYear();
var month = now.getUTCMonth() + 1;
var day = now.getUTCDate();
var hours = now.getUTCHours();
var minutes = now.getUTCMinutes();
var seconds = ...
-1
votes
1
answer
31
views
How to use reg-ex group matching in javascript (Python equivalent)?
import re
items = ["abc","def","a123","bgh5"]
ele_list = ["dsdsd-vfvfv-abc.xyz.com", "lbebbe-fjhdhf-abc.xyz.com", "bdfhjd-bjsbjd-bgh5....
1
vote
0
answers
66
views
How to transpile inline and external JavaScript in an HTML to ES5
I have HTML files with script tags, containing either ES6 code or CDN links to modern JavaScript libraries (such as lodash). I need to have all the code in ES5, since it's required by the Prince ...
0
votes
1
answer
2k
views
This language feature is only supported for ECMASCRIPT_2015 mode or better: block-scoped function declaration
I have two banners that needs to be displayed when one of the divs exist on my HTML, I've made this script and it works perfectly. The problem is that I'm using GTM and it gives this error: "This ...
0
votes
2
answers
52
views
How to match Time Ranges in Java or Javascript any?
I have two Data formats and need to compare them. But the prbolem is in 2nd format the Day(Mon, Tue) is in value and in 1st format it is in Variable side, So how I can compare the day.
I have to ...
1
vote
5
answers
504
views
Find unique array of objects dynamically considering undefined values
I have a an array of objects in this format:
const myArray = [
{
one: 'A',
two: 'AB'
},
{
one: undefined,
two: 'AB'
},
{
one: 'A',
two: 'BC'
},
{
one: undefined,
two: 'CC'
},
]
...
0
votes
0
answers
108
views
Nuxt.js problematic nuxt.config.js/ts with Firebase Cloud Functions while deploying ES5/6 modules / compatibility issue
I'm trying to deploy Nuxt.js (2) SSR app to Firebase Hosting/Functions. I'm able to do that, as long as I won't include nuxt.config.ts in functions/src/index.ts. However, I do have some setup there, ...
1
vote
2
answers
767
views
How to type prototype-based ES5 class in TypeScript?
I am in the process of converting some of the old ES5 projects to TypeScript. In these projects, there are old-style classes (functions) defined as follows (simplified examples):
function MyClass(arg1)...
-1
votes
1
answer
121
views
Convert nested objects containing mixture of arrays and objects into a different structure using Javascript
I am having a nested object that looks like this. This contains nested arrays and objects inside it. It looks like this,
const input = {
result: {
data: {
groupMapper: [
{
...
2
votes
1
answer
140
views
Proper subclassing of built-ins in ES5, counterproof to MDN statement
I'm writing some in-depth educational materials about the object model, constructor functions and class mechanisms in Javascript. As I was reading sources I found this statement that I took the time ...
0
votes
1
answer
156
views
Cypress: can't pass a map as mocked rest call response
I'm trying to mock a rest call in Cypress. This rest call should return a map as response, e.g.:
cy.intercept('POST', 'path', new Map([['a', 'abc']])
The problem is that this will return an empty ...
1
vote
0
answers
60
views
Why loop statement itself has a return value in ECMAScript?
According to ECMAScript Language Specification 262, for-loop has a return value.
link : https://tc39.es/ecma262/multipage/ecmascript-language-statements-and-declarations.html#sec-runtime-semantics-...
0
votes
1
answer
442
views
How to import lodash into a JavaScript file
After installing packages e.g. lodash using npm install --save lodash, I am trying to add it to the top of the file.
import _ from 'lodash';
console.log(add(10, 3));
When I start Live Server from VS ...
1
vote
1
answer
153
views
Return object comparing input with nested objects
I am having an object that looks like this:
const obj = {
"cat1" : {
id: "1",
name: "Category1",
tiles: [{ tileName: ...
0
votes
1
answer
221
views
npm pack removing file extensions from import
I'm trying to a create an internal library for work.
All seems to be fine until I attempt to use in another project.
The file extension in all of the import statements seems to have been removed ...
0
votes
4
answers
96
views
Filter an array of object using filter array [duplicate]
I'm trying to filter an array using 2 criteria :
one is straigthforward (==1) and the other is an array.
In the below example, i would want to filter :
level = 0 or name comprises in ['B','S']
[
{id: ...
-3
votes
2
answers
82
views
Facing problem I want to print only Number not any other character like NaN [duplicate]
When I put Character in prompt the character is printed...
var myNumber = prompt("What is your Number");
var myName = prompt("What is your name");
if (NaN != myNumber) {
document.write("My ...
0
votes
1
answer
553
views
how ES7 import module's object in Node.js
var GoogleStrategy = require('passport-google-oauth20').Strategy;
How can I use ES2017's way to write it? I try
import GoogleStrategy from ('passport-google-oauth20').Strategy
But it couldn't work
...
1
vote
0
answers
68
views
Create a vue-like plain component
Entry level. ES5 standard.
I have built a module:
import Person from './Person.js';
function Employer()
{
Person.call(this);
this.randomMethod = function() {
console.log('...
0
votes
0
answers
934
views
VueJS Problem with DigitalPersona 4500 SDK import
I bought one digital persona 4500 and I want to know if it works with VueJs project ? If yes, can you let me know a tutorial where I can try to do it ?
I have an error on importing the Fingerprint ...
0
votes
1
answer
679
views
Convert Nested object into custom array of objects: Javascript
I am having array of objects that look like this
const test = {
a: { name: "A", selected: [1, 2, 3], display: [1, 2, 3] },
b: { name: "B", selected: [4, 5, 6], display: [4, 5, ...
0
votes
4
answers
85
views
Convert nested aray into group of objects: Javacript
I am having an object that has the following structure
const arr = [
{field: "f1", values: [{ count:1, value: "a"}, { count:2, value: "b"}] },
{field: "f2", ...
2
votes
1
answer
312
views
Why is `const` a reserved keyword in JS but `let` isn't
Looking at JS Reserved words (MDN), it looks like new features are introduced in backwards-compatible manner, meaning var let = 0, async = 1, await = 2; is a valid expression, at least outside strict ...
0
votes
1
answer
335
views
Apply child value to parent key if specific key exists in child in object
const obj = {
uid: "893212",
a: {name: "Down here!", uid: "1231"},
b: {
c: {uid: "5965"},
name: "bud name",
},
d: {name: "...