1,381 questions
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
37
views
Exporting uesState variable into another component/page
I'm a bit stuck. I've put the users input results into an array that can be used on another component. However when I try to destructure the 'newList' in another component/page it doesn't show ...
41
votes
10
answers
26k
views
Destructure array to object property keys
I have an array of values like:
const arr = [1,2,3];
Is there any way I can use destructuring to create the following output? If not, what is the easiest way I can do this in ES6 (or later)?
const ...
7
votes
2
answers
1k
views
How to shadow existing variables when destructuring in C++?
Is there any way to shadow existing variables when destructuring a std::pair? For example if I have the following functions defined:
#include <iostream>
#include <utility>
std::pair<...
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 ...
11
votes
1
answer
54k
views
Typescript Object destructuring results in "Property assignment expected."
I am transitioning a project from Babel to Typescript and receive the following compiler error:
error TS1136: Property assignment expected.
from code that looks like this:
var auth = {...this.props....
187
votes
3
answers
122k
views
Destructuring and rename property
const a = {
b: {
c: 'Hi!'
}
};
const { b: { c } } = a;
Is it possible rename b in this case? I want get c and also rename b.
13
votes
2
answers
73k
views
TypeError: Cannot destructure property `db` of 'undefined' or 'null'
I am getting a TypeError in my variable assignment for mongodb connection. Is there a workaround for this?
//server.js
var mongoose = require('mongoose');
var config = require('./config');
var { db: ...
1
vote
3
answers
798
views
Destructing string array optional parameters in TypeScript?
I need to implement a string concatenate function, the functionality shows below,
function concatenation(original: string, name1?, name2?){
return original + name1 + name2;
}
However, the question ...
183
votes
14
answers
82k
views
One-liner to take some properties from object in ES 6
How one can write a function, which takes only few attributes in most-compact way in ES6?
I've came up with solution using destructuring + simplified object literal, but I don't like that list of ...
0
votes
3
answers
66
views
React - How to Set a checkbox from props using array destructring
There is a React MUI Datagrid with list of users and when a user row is clicked, another dialog window opens with individual details of an user. I use props to send the value from DataGrid to Dialog.
...
22
votes
3
answers
30k
views
How do I destructure a vector without taking a slice?
I can destructure a vector of tuples by taking a slice of a vector and references to the items within the tuple:
let items = vec![("Peter".to_string(), 180)];
if let [(ref name, ref age)] = items....
21
votes
3
answers
7k
views
How to perform assignment destructuring using the walrus operator in Python
I can do an assignment destructuring as:
a, b = s.split(' ', 1)
for a string s which has more than one word.
How can we do the same in, say an if or elif, with the latest assignment expression ...
1
vote
1
answer
327
views
Spread operator and destructuring
interface Item {
id: string;
title: string,
}
interface ItemState {
entities: { [id: string]: Item };
}
const toBeDeleted = { id: '2', title: 'item_2' };
const state: ItemState = {
...
41
votes
3
answers
55k
views
Java object destructuring
In javascript there is object destructuring so we can break down objects and just use the end key if the intermidiate objects are resused multiple times. e.g)
const person = {
firstName: "Bob",
...