All Questions
58
questions
0
votes
1
answer
19
views
Make object key as value and assign new key to value in array of objects
I have an array of objects with multiple properties. I want to be able to make the property's key a value and assign a new key to my value.
My code:
var list = [
{
you: 100,
me: 75,
...
-1
votes
1
answer
24
views
Add to object with every iteration without replacing
I have an object outside of the function that I want to populate with every iteration and call that object after the iteration is done but I am only able to see the last element in my object. How do I ...
0
votes
0
answers
150
views
Create array of objects from graphql response
I have a response from graphql that I want to reformat and assign to a variable so that I can keep using them across my app.
GraphQL response:
{
"data": {
"organization"...
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 ...
-1
votes
1
answer
565
views
Arrow Function Created In An Object Returns undefined When Called Using .call() Method [duplicate]
i just created an object with an arrow function :
const user={
fName:"0xN1nja",
about:()=>{
return this.fName;
}
}
now, when i call that arrow function with .call() ...
0
votes
3
answers
88
views
Find object by specific key in a deep nested object | Javascript
What is the cleanest way to find object and return that based on id , If I don't know how many nested object there will be in my object ?
Let's say I have the following structure :
myObj = {
...
0
votes
2
answers
444
views
Best way to set variables from an array of objects
I have the following code which feels a bit redundant as I'm iterating over the same array many times, any suggestions to improve while keeping it readable would be appreciated.
The array object ...
2
votes
3
answers
89
views
Can't access function after name changed in node.js
There is a function in one of my files in project which I changed it's name and can't access it with new name! still the old name is available to call
I tried deleting node_modules and install it ...
0
votes
1
answer
95
views
return this returns undefined
I have a helper method called magnitude that I tried to use chaining functions with it.
That is my magnitude.js:
export const Magnitude = props => {
let data;
const formatterObj = {
...
-1
votes
1
answer
2k
views
JavaScript: Add Key and Value to Object Using ES6 {} Shortcut
I have the following object:
obj = {name: 'Amy',
age: 36,
type: 'sanguine'}
I want to add another key and value to the above object, but I specifically want to do that using the {} ...
0
votes
2
answers
34
views
Perform initial task with parameters before executing function in JS
I'm making a tool. This tool should be able to accept parameter, perform an initial task to the parameters, then return a result depending on which function is invoked.
My first attempt was using an ...
0
votes
1
answer
77
views
Using 'this' in javascript function attached to object property [duplicate]
Edit:
The question referred to as the duplicate doesn't really answer why arrow functions shouldn't be used to access a non-lexical this. It just answers that arrow functions automatically bind this. ...
1
vote
2
answers
44
views
Defining methods/functions on Javascript Objects
Is this:
saveUpdate() {
// Some code
}
The same as:
saveUpdate: function() {
// Some code
}
Is there a best practice (ES6) way to define methods on objects (specifically, Vue.js components)?
...
0
votes
2
answers
240
views
How to get object from which function was called?
Here is one of mine difficult to answer questions.
I am trying to create a function which can detect from what object and what property it was called. The function has to work for any method or any ...
0
votes
3
answers
59
views
JS function that logs properties of nested objects, where properties are passed as parameters
I have the following object:
let a = {
aa: {
aaa: 1
},
ab: {
aba: {
abaa: 2
}
}
}
I want to write a function to which you can pass an object plus ...