All Questions
Tagged with object properties
1,191
questions
0
votes
1
answer
43
views
getting error when modifying the javascript property using Object.defineProperty()
obj = [{
prop11: 'value1',
prop21: 'value2'
},
{
prop12: 'value1',
prop22: 'value2'
},
{
key3: {}
}
];
obj.forEach(element => {
Object.defineProperty(obj.key3, '...
109
votes
18
answers
163k
views
Get object property name as a string
Is it possible to get the object property name as a string
person = {};
person.first_name = 'Jack';
person.last_name = 'Trades';
person.address = {};
person.address.street = 'Factory 1';
person....
-3
votes
2
answers
2k
views
Append associative element from a flat array as a new property of the first object in an array
I need to merge two Associative Arrays with one.
first array
Array
(
[0] => stdClass Object
(
[c_id] => 743
[userid] => 570c842ce6073
[postid] ...
1028
votes
46
answers
1.5m
views
Sorting object property by values
If I have a JavaScript object such as:
var list = {
"you": 100,
"me": 75,
"foo": 116,
"bar": 15
};
Is there a way to sort the properties based on value? So that I end up with
list = {
"...
977
votes
21
answers
662k
views
Accessing an object property with a dynamically-computed name
I'm trying to access a property of an object using a dynamic name. Is this possible?
const something = { bar: "Foobar!" };
const foo = 'bar';
something.foo; // The idea is to access something.bar, ...
1
vote
2
answers
248
views
Unable to access JavaScript Object property from CSV file
I am having a hard time figuring out how to access a property of my javascript object.
I have a Node JS application that downloads a CSV file from the WHO with covid data and then I loop through each ...
7516
votes
39
answers
3.3m
views
How do I remove a property from a JavaScript object?
Given an object:
let myObject = {
"ircEvent": "PRIVMSG",
"method": "newURI",
"regex": "^http://.*"
};
How do I remove the property ...
97
votes
5
answers
107k
views
How to create new property dynamically
How can I create a property from a given argument inside a object's method?
class Foo{
public function createProperty($var_name, $val){
// here how can I create a property named "$var_name"
...
61
votes
13
answers
50k
views
How to prevent automatic sort of Object numeric property?
Why I met this problem:
I tried to solve an algorithm problem and I need to return the number which appeared most of the times in an array. Like [5,4,3,2,1,1] should return 1.
And also when two number ...
-1
votes
1
answer
24
views
I am trying a display items (events) from db typescript nestjs using handlebars the events are an array of object. Properties of each object undefined
please look at the way i am passing the events check for the issue
@Get('views/users/events')
async findAllEvents(
@Req() req: Request,
@Res() res: Response,
@Query('page') page: number = 1,
@Query(...
331
votes
6
answers
387k
views
Is there a “not in” operator in JavaScript for checking object properties?
Is there any sort of "not in" operator in JavaScript to check if a property does not exist in an object? I couldn’t find anything about this around Google or Stack Overflow. Here’s a small snippet of ...
0
votes
0
answers
16
views
powershell array of object with dynamic properties outputs only properties from first element [duplicate]
why ? and how to fix this ? how to export to csv file now after export i receive the same as when displaying $res.
$res= @()
$obj = [PSCustomObject]@{}
$obj | Add-Member -MemberType NoteProperty -Name ...
0
votes
2
answers
32
views
Object property has different many string values
I have objects, that has different properties, one of them is programingLanguage. So, with the function, I want to check if the object property - programmingLanguage has a value of "Java". ...
0
votes
4
answers
90
views
How can I write a function that returns the objects in an array that have the two same property values?
Let's say I have the following object:
const myObjects = [
{ name: "Alice", age: 30 },
{ name: "Bob", age: 25 },
{ name: "Alice", age: 30 },
{ name: "...
0
votes
1
answer
32
views
Explanation on access an object property that does not exist on an DOM element
I am a beginner on JavaScript, looking for a explanation on accessing to an object property that does not exist on an DOM element.
I am working on a todo apps. Below is my current code but it is not ...