7,174 questions
0
votes
2
answers
53
views
Can't use properties and methods from the object passed as an argument to the Phaser event handler function [closed]
I'm developing a card game using Phaser, and I ran into some really weird behaviour.
I'm using built in Phaser EventEmitter object for handling some card effects.
EventEmitter example:
const ...
-5
votes
1
answer
113
views
Why does `\\"` inside a string still result in `\"` after parsing? [closed]
I’m trying to understand how JavaScript string escaping works at the parser level.
Consider this example:
const json = '"{\\"name\\": \\"John\\", \\"age\\": 32}"';
console.log(json);
When I run this, ...
1
vote
1
answer
142
views
Are dynamic property tags in JS object literals possible?
I'm building my first framework. I need to be able to generate a semi-dynamic object, to which end, I want to re-use a single variable that points to a unique-value-returning function. I have a JS ...
-7
votes
1
answer
192
views
How should I efficiently add all pairs in a key-value array to an object?
I have an object obj; and I then obtain an array arr of key-value pairs. Assuming that the key sets of obj and of arr are disjoint (i.e. no key appears in both) - how do I efficiently add all pairs in ...
25
votes
2
answers
2k
views
Why do JavaScript Websocket objects not get destroyed when they go out of scope?
In JavaScript, when you do something like this,
function connect() {
var ws = new WebSocket(url);
ws.onmessage = function(e) {
window.alert(e.data);
};
}
it will work. But why ...
1
vote
1
answer
105
views
Google Maps Custom Style Not Applying in WordPress (Elementor)
I’m working on a WordPress website using the Elementor Pro page builder, and I’m trying to integrate a custom-styled Google Map on the "Contact Us" page.
What I’ve done so far:
Created a ...
-1
votes
1
answer
95
views
How do I declare a function async in a JavaScript object literal/initialiser?
I'd like to have the loadConfig function async and just finish after the resource has been loaded. await fetchetc. How can I declare it in this object syntax as an async function?
var QMEM = QMEM || {
...
0
votes
0
answers
190
views
Issue with Injecting Text into WhatsApp Web Input via JavaScript Extension
I'm working on a JavaScript extension for WhatsApp Web, and I'm facing a problem I can't seem to solve. The goal of my extension is to correct and manipulate the text in the message input of WhatsApp ...
0
votes
0
answers
45
views
Why does offsetHeight log an increased height when called from object than what is shown in the object log itself?
I have an object taken from the DOM who's actual offsetHeight I can not correctly get.
When trying to console.log the object to check the property, it does show the correct offsetHeight. But when I ...
0
votes
0
answers
27
views
Storing an object key/value in an array but not in an array element [duplicate]
I found some odd things and am looking for explanations as to how and why
let a = [] ;
a.push({foo:"bar",bar:"foo"}] ;
console.log(a) ;
As expected, prints out:
[[object Object] {
...
-1
votes
1
answer
67
views
Question about Javascript: Can I assign two names to the same member? [closed]
I have a set of objects, that contain references to other objects. There is always a general reference: nextObject. But sometimes, I know more about the object beside me. So I could use a member ...
0
votes
1
answer
46
views
Intantiating a Javascript extended class from Array with only one element
I am implementing an extended class from Array with numerical methods such as sum, mean, std, etc.
There is no problem to instantiate an object with zero or 2+ elements, but I can't implement one-...
-5
votes
1
answer
118
views
Javascript cannot map object with repetative values
I need to style specific elements by id using given object.
Keys and values in projectSkillsMap object corresponds to ids in html file. When user clicks on element with id listed in object keys ...
-5
votes
1
answer
102
views
Initiate all potential props of the object right away or as you go? [closed]
I'm my scenario I have to create a lot of objects (100k+). Those objects can 'evolve' in the course if their life. Some will stay practically unchanged, others with will mutate and have a bunch of ...
0
votes
1
answer
84
views
How to retrieve the name of an Object passed as a Key to a Map?
I'm a newbie to Javascript. I wish to know how to get the key as 'personObj', 'carObj, 'workDetailsObj', 'displayFunction' and 'primitiveValue' and print those values in console? Also, how to print ...