All Questions
54
questions
-2
votes
1
answer
271
views
JavaScript get comma separated values based condition
Hi I'm having an issue filtering out the values from array of objects. So basically I've an array of object
const arr = [
{
"id": null,
"name": null,
&...
0
votes
3
answers
287
views
Is there any way to create object using function in TypeScript , like JavaScript?
I want to create Object using Function in TypeScript like JavaScript.
Eg.
function Box(a,b) {
this.width=a;
this.height=b;
}
var box=new Box(3,5);
I tried this code in TypeScript, It throws ...
0
votes
2
answers
47
views
How to take only specific indexes and map to another indexes?
I need to make an api call with particular parameter.
See example below:
const apiFunc = (someId, anotherId) => apiCall(someId, anotherId) }
However in an array called someArr I get something like [...
0
votes
1
answer
35
views
How to replace object props inside array with other object
I have an array of objects like this one:
let arr1 = [{
"ref": 1,
"index": "300",
"data": {
"id": 10,
"status": {...
0
votes
2
answers
200
views
How to get array of objects by object and arrays in javascript
For the array of object, compare with object and list array using javascript
should get the array of objects based on below conditions
itemvalue and idvalue same, from that check arrobj cid has same ...
4
votes
3
answers
1k
views
How can I spread array elements into an object as the keys, and define some value for them?
Let say I have an array:
const arr = ['a', 'b, 'c'];
I want to create an object like this:
{ 'a': true, 'b': true, 'c': true}
How can I do this?
const obj = {...arr: true}
did not work
1
vote
1
answer
1k
views
ES6 typescript class create object of itself inside
I have created a class and inside that class i want to create an array that consist of object of itself. In normal javascript if achieve it as follow
class Person{
constructor(name){
...
0
votes
2
answers
383
views
Transform a number to string inside an array of objects
Having the following input array:
const input = [
{
id: 1,
name: 1
},
{
id: 2,
name: 2
},
{
id: 3,
name: 3
},
{
id: 4,
...
4
votes
1
answer
1k
views
How to copy values of only a subset of object properties to another existing object in TypeScript
Lets say I have an existing object obj1 = {a: 'A', b: 'B', c: 'C', d: 'D'}
I have another object something like obj2 = {b: 'B2', c: 'C2', d: 'D2', e: 'E2'}
Now I want to selectively copy the values of ...
1
vote
2
answers
611
views
Convert deeply nested class object to plain object while preserving methods?
There's a class object (deeply nested with more class objects) and I'd like to convert it to plain Object type while preserving methods (getters, setters, etc).
class A {
id = "";
...
2
votes
1
answer
1k
views
How to filter nested arrays by searching
I have an array of objects that I want to filter by comparing a nested property to a search term.
For example:
let array = [
{
category: 15,
label: "Components",
value: "...
0
votes
2
answers
281
views
Flatten nested object in array of objects
Im using Typescript and I have this object structure:
{
a: "somedata",
b: "somedata2",
c: [
{
name: "item1",
property1: "foo",
...
0
votes
1
answer
870
views
Destructuring in ES6 syntax of of req.body gives me the whole object instead of specific value
it's probably a lack of understanding but this is the first time this is happening. My function looks like this:
exports.handleFormSubmit = functions.https.onRequest(async (req: Request, res: Response)...
1
vote
4
answers
2k
views
Find empty keys in array of object using javascript (Es6,typescript)
I have an array of objects. In that array of objects I have to find which keys have empty value with index of array. Array list is given below:
let fruits=[
{name:"apple",quantity:2,price:"" },
...
2
votes
2
answers
718
views
How to find if a specific key is true in Array of objects
I have this array and I want to to get a boolean(true) if there is a 'three' that is equal to 9
myArr = [
{
apple: 6,
basket: [
{
one: 1,
two: 2,
...