Skip to main content
Filter by
Sorted by
Tagged with
1 vote
1 answer
67 views

I'm using the Angular FormBuilder (import { FormBuilder } from '@angular/forms';) to create my FormGroup and inner FormControls as this right now: formGroup = new FormBuilder().nonNullable.group({ ....
Kevin Cruijssen's user avatar
0 votes
1 answer
48 views

I couldn't find any information about this in the AssemblyScript docs. Is the spread operator available in AssemblyScript? I would like to define an object like so: { ...params, category: "...
Paul Razvan Berg's user avatar
0 votes
2 answers
62 views

Have a code (typescriptPlayground) problem is in spread operator. in case of secondObjectFull i have an error. It is ok. firstObject cannot spread to secondFullMapped But in case of thirdObjectFull ...
Andrew M's user avatar
-2 votes
3 answers
63 views

I have 2 arrays, each is like a database table row set. array1 = [ ['AB2C', 'Red', 113], ['BE4F', 'Green', 164], ['AE3G', 'Blue', 143], ] array2 = [ [143, 'FabricB2', 'W5'], [189, 'FabricC9', 'W4'], [...
Liquid Nitrogen's user avatar
0 votes
0 answers
70 views

I have an object of methods which I am seeking to extend with copies of those methods but scoped to a given method e.g. the method fetchOnce() will have copies postOnce(), getOnce() etc. The original ...
wheresrhys's user avatar
  • 23.7k
0 votes
3 answers
267 views

Let's say we have the following base list: [["foo"],["bar"]] and the input string "a" I want to prepend the input string to each list in the list, which results in: [[&...
rph's user avatar
  • 2,679
0 votes
1 answer
80 views

For matrix transformation i use wgpu-matrix library. I already have implemented raycast (hit object trigger) in other project. I wanna implement it also in my new project matrix-engine-wgpu. In this ...
Nikola Lukic's user avatar
  • 4,274
0 votes
2 answers
180 views

let arr = [ {id: 1, data: {foo: "bar 1"}}, {id: 2, data: {foo: "bar 2"}} ]; //In case the ID does not exist just add as a new element on the array arr = [...arr, {id: 3, data: {foo: "bar 3"}}] ...
David's user avatar
  • 668
1 vote
1 answer
82 views

I'm new to generics in typescript, it's confusing is there a way to make the spread operator ... work in the snippet below the issue the line [ key: U, ...rest: Reg[U] ], doesn't work as I expect the ...
azzmi's user avatar
  • 75
2 votes
1 answer
356 views

I have a backend model with some properties that I want to be able to send to the frontend with certain properties excluded. I'd like to use typing to help me ensure they have been excluded. I tried ...
Tom's user avatar
  • 2,454
1 vote
0 answers
32 views

how to extract partial attributes of an object using typescript types? is it even possible? export interface Product { brandName: string; modelNo: string; rate: number | null; someOtherProp1: ...
muon's user avatar
  • 14.2k
1 vote
0 answers
43 views

I have a code sample below that demonstrates this. I ran into this unexpected behavior of the spread operator where a key that gets set as undefined is not treated the same way keys that have never ...
Summitch's user avatar
  • 385
1 vote
4 answers
177 views

Suppose the following: const arr = [1, 2, 3]; const insertValues = [-1, 0]; const condition = true; arr.splice(0, 0, condition ? ...insertValues : insertValues); This throws a syntax error: ...
Mike K's user avatar
  • 6,625
0 votes
0 answers
60 views

In my state I have a dictionary of a flat object: export interface INodeVisibility { id: string; level: number; isExpanded: boolean; } export type NodeVisibilityDict = { [key: string]: ...
Sammybar's user avatar
1 vote
1 answer
128 views

I tried to use spread operator to avoid modifications of my state without the use the set State. But despite that, my state is still modified. I can eventually make a deepCopy of my state but I don't ...
Poumon's user avatar
  • 61
0 votes
2 answers
84 views

I am currently working on a React project and encountered an interesting issue related to shallow copying objects. In my component, I have a form where I collect data, and I noticed that different ...
Ibai Fernández's user avatar
-1 votes
1 answer
133 views

I know that the assignment of one variable to another is done by shared reference so that when you set var c = b; and then you do some change change to c such as c.cool = 'new'; then b gets affected ...
Octo Palm Tree's user avatar
3 votes
3 answers
323 views

I'm trying to insert some values in a Google sheet using a Google Apps Script, but when I'm spreading the range that I defined earlier, it only returns the first value. I expected Logger.log(......
Vitis vinifera's user avatar
0 votes
0 answers
83 views

StackBlitz for this problem I want to create some constant pipes and import them all together in app.module.ts. It works when I use syntax like export const pipes = [MinValue, MaxValue], but does not ...
LittleSaya's user avatar
-2 votes
1 answer
182 views

I want to be able to bundle the properties of multiple objects into another object by reference, such that when I change the properties in the bundle object it mutates the original objects. I'm using ...
Robert M.'s user avatar
  • 613
1 vote
2 answers
1k views

The syntax is identical so how does JavaScript distinguish the two under the hood? Does it look at the data type of the variable that is being operated on? Or where that variable is being used? Both ...
Jennifer's user avatar
4 votes
8 answers
712 views

I have an object and an array. Say: const first = { 'key1': 'some date', 'key2': 'some date' } const second = ['key3', 'key4'] Then using spread syntax I want to combine then into single object....
Zobla's user avatar
  • 123
2 votes
1 answer
61 views

I have this code in JavaScript what is the difference between the lines A and B ? const arr1 = [1,2,3,4,5] const arr2 = [...arr1]; // Line A const arr2 = arr1; // Line B I want to know is it ...
Srajal Dwivedi's user avatar
1 vote
1 answer
24 views

This is the narrowed down code from my actual use case. function wrapMe<F extends (...args: any) => any>( f: F, ): (...args: Parameters<F>) => ReturnType<F> { return ...
joegomain's user avatar
  • 884
0 votes
1 answer
50 views

I have a playground for this question here. In the following code, typescript does error on the assignment to t2_2 ("not assignable") but not on t2_1, where I have the "x" property ...
andreash's user avatar
  • 123
0 votes
0 answers
30 views

I understand about JavaScript spread syntax in general. But in the following code, I cannot understand why it is used when creating a new array of specific length: const createArray = length => [......
Zonaed Hasan's user avatar
1 vote
1 answer
317 views

interface Item { id: string; title: string, } interface ItemState { entities: { [id: string]: Item }; } const toBeDeleted = { id: '2', title: 'item_2' }; const state: ItemState = { ...
edd's user avatar
  • 59
8 votes
6 answers
3k views

I want to perform Destructuring in php just like in javascript code below: [a, b, ...rest] = [10, 20, 30, 40, 50]; console.log(a,b,rest); Output: 10 20 [ 30, 40, 50 ] How can I preform that ...
Zaid Malek's user avatar
1 vote
1 answer
416 views

I've got a function which is expected to return an object with specific keys. In my case, I only want to add the keys conditionally, so I am using spread syntax to help with that. However, when I use ...
ThePuzzleMaster's user avatar
0 votes
2 answers
136 views

I have the following code that includes Spread Syntax in JS const opposite = function (f) { return (function (...args) { return !f(...args) }) }; can it be converted without using Spread Syntax? It ...
Olivier Sin Fai Lam's user avatar
2 votes
2 answers
662 views

I'm testing spread operator inside array to map another array values. Unfortunately, I have come up with weird behavior or I did it wrong. When I return 2 objects using map inside the array, it's only ...
83hru2's user avatar
  • 359
2 votes
5 answers
1k views

Consider the following data: let data = [ { foo: true, bar: [ 1, 2, 3 ] }, { foo: true, bar: [ 8, 9, ] } ]; I'm trying to push something to the nested bar array on index 1 using the spread ...
0stone0's user avatar
  • 45.5k
1 vote
1 answer
89 views

So I have an array of objects where the keys are 'cost' and 'service' called estimate. You can add to the array by clicking 'Add' which adds a new index (i) to the array. The issue is on the first ...
mattr534's user avatar
1 vote
3 answers
107 views

I'm working with a JavaScript object that gives the default values for a library I am working with const defaults = { alpha: alpha_val, beta: { a: { i: beta_a_i_val, ii: ...
always_learning's user avatar
1 vote
2 answers
63 views

I have an object that contain a property with an array of objects which I have to change one object. {id: '3688aa8f-e725-45f4-9513-363a1c019b34', category: 'Entertainment: Film', difficulty: 'easy', ...
Asaph Ferreira's user avatar
1 vote
0 answers
2k views

I've read up on the es6 object spread operator and I've come across it being used in a react tutorial to spread props into a component. I can't understand how this is working though, for instance ...
j obe's user avatar
  • 2,097
1 vote
2 answers
293 views

There is a well known symbol: Symbol.iterator, that, when defined as a generator function property on an object, allows the object to be used in a [...object] syntax. So, you can do, eg., this: const ...
Aleksandar Bosakov's user avatar
1 vote
2 answers
94 views

What I'm looking for is to have a function with infinite number of parameters and each parameter type is based on if its index is even or odd. A contrived example: flow(isMachineReady(), 'and', ...
hassan salehi's user avatar
0 votes
3 answers
197 views

const defaultFormFields = { displayName: "", email: "", password: "", confirmPassword: "", }; const SignUpForm = () => { const [formFields, ...
Muhammad Usman's user avatar
1 vote
2 answers
1k views

I'm still a newbie in React and I've been struggling for some time with the topic mentioned above. I've got a state which looks like this: const [questions, setQuestions] = React.useState([]) ...
Kotetsu's user avatar
  • 13
1 vote
2 answers
214 views

Why does this code print Array(7) [ <7 empty slots> ] (or an array of undefined, 7 times) instead of an array with the single element 7? const a = [ 7 ]; console.log(new Array(...a));
aramattamara's user avatar
0 votes
1 answer
45 views

Apologies for the terrible title I didn't know how else to word it. this is a kata im trying to complete in codeWars. Drone Fly-by. basically the lamps parameter will be a string of 'x' characters and ...
Jondon1337's user avatar
0 votes
4 answers
103 views

I have this clunky code here and hope there is any way to shorten this. By the way, "req.query" is my query object from an nodejs express server. const q = req.query User.insertOne({...
Gehmasse's user avatar
4 votes
2 answers
6k views

can you do this in C++: vector<int> v1={1,2}, v2={3,4}; vector<int> v3={...v1, ...v2, 5}; //v3 = {1,2,3,4,5} What is the simplest way to do this with C++ ?
Ludovic Aubert's user avatar
3 votes
1 answer
3k views

I am new to TypeScript and I am going to change my project to TypeScript. But I got some error. I have searched about the spread arguments but I can't figure it out correctly. This is I tried so far. ...
Lukas0320's user avatar
1 vote
1 answer
142 views

Here is my code: let collection = database.collection('documents') let savedDocumentsCollection = database.collection('savedDocuments') let doc = await collection.find().toArray() let saved_documents =...
bobthebuilder's user avatar
0 votes
1 answer
160 views

I have the following code as part of grabbing data from a query and appending it to a local state that is stored as an object. However, this following code using the spread operator (...) is not ...
user avatar
4 votes
1 answer
301 views

How does the spread operator within the array destructuring of y3 work? The result would contain both 'lizard' and 'spock', but because of the spread operator around the square brackets, it somehow ...
Cjmaret's user avatar
  • 329
0 votes
0 answers
652 views

I am trying to replace an instance of hardcoding in a web application with 2 very similar API calls, as I don't have time to rewrite a whole new procedure and endpoint to handle the same functionality ...
Walter Tracey's user avatar
0 votes
0 answers
53 views

Trying to figure out why the spread operator is needed in the code below in order for it to produce a return. When I delete the ..., no return is produced. function binaryAgent(str) { return String....
BillyG's user avatar
  • 9

1
2 3 4 5
10