1,381 questions
2
votes
1
answer
184
views
Does JavaScript object destructuring allocate a new object?
In the following JavaScript, does the object destructuring that follows the creation of target create a new (temporary) object that has to be garbage collected? In other words, are there two objects ...
-1
votes
1
answer
46
views
Destructure and don't destructure variable at the same time in svelte
I was wondering if it's possible to have access to entire object inside if/for, but still be able to destructure individual props
{#if object_var}
{const {prop_var} = object_var}. <- doesn't work,...
-1
votes
1
answer
52
views
How to use destructirng assignment combined with looking up elements on the page?
I want to reduce my javascript code. I have:
let c = document.querySelectorAll(".check"),
l = document.querySelectorAll(".label");
I want to have, for example:
let [c, l] = ...
3
votes
3
answers
331
views
Unpack table into same-named variables
If I have a table with known properties, but where the order of the properties is potentially unknown:
local person = {
name = 'James',
age = 30,
}
can I reliably destructure it:
local name, ...
2
votes
1
answer
526
views
Why I'm receiving an "Unsafe array destructuring" on an object destructuring in TypeScript?
I have a problem in TypeScript with an IteratorResult destructuring. I'm doing a simple object destructuring and I'm getting an array destructuring error.
This is the code that is throwing the ...
1
vote
1
answer
29
views
Express CRUD operations "Cannot read properties of undefined (reading 'comment')"
I am building a simple app that displays an index of comments, allows posting of new comments, and editing+deleting of existing comments. I do this following Colt Steele's course section 371.
At a ...
0
votes
1
answer
129
views
Destructuring in a Ruby block when using index
Without using index I was able to destructure the first and second elements of an Array of Arrays like so:
[ [ 1, 2 ], [ 3, 4 ] ].each do |first, second|
puts second
end
#=> 2
#=> 4
I then ...
2
votes
1
answer
59
views
Cannot destructure value from a DOM element when using ES6 rest
Given the below JSBIN why A is undefined?
https://jsbin.com/bisomevivu/edit?html,js,console,output
HTML:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<...
1
vote
1
answer
151
views
Destructuring in Dart not working as expected
I am going through the language tour and, coming from a mostly Javascript background, I'm having trouble understanding how to destructure this record.
(int, String, {String b, String c}) rec = (7, c:&...
2
votes
9
answers
559
views
Create 2 arrays with reduce method
I have an array of objcets. With reduce method after looping i want to receive two seperate arrays. Now, i am doing this way.
const dogs = [
{ weight: 22, curFood: 250, owners: ['Alice', 'Bob'] },
...
3
votes
3
answers
1k
views
How to make Serilog destructuring operator ignore properties with null values?
Is there a way to tell Serilog not to serialize null-valued properties of objects logged using the @ (destructuring) operator? I found a couple of posts on the topic (actually, I found more, but these ...
0
votes
1
answer
146
views
How to display an object from server side to client side as a chart using express+ejs+chartjs?
I am trying to pass two objects weights(list with integer value) and progressDatas(list with string value) from the server side to the client side. In the client side I am stuck at how to render the ...
1
vote
0
answers
31
views
Invalid attempt to destructuring non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method
I am building a react native application to display nearby hospitals. The error is at AppMapView & ListView component
const [placeList, setPlaceList] = useState([]);
ere, placeList is not empty. ...
-1
votes
2
answers
125
views
Dynamic or conditional based Promise.all() and destructing
I want to get data from DB based on the boolean flag.
async function main() {
let promises = [];
if (false) {
promises.push(Promise.resolve("highlights from DB"));
}
if (true) {...
3
votes
4
answers
837
views
Is it possible to do conditional destructuring of a union type in typescript?
I have a React application (although the question is not really about React), with typescript.
In a functional component (whose consumer I want to be able to pass OR styles OR a class, but not both), ...