All Questions
Tagged with object properties
1,192
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, '...
-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(...
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
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 ...
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
0
answers
26
views
Why I need to access multiple nested properties of an object? [duplicate]
Please don't close my question. Earlier it was closed with a wrong solution, Assignment with double ampersand "&&".
Please help me understand the Redux code. Why can't I use directly ...
1
vote
1
answer
40
views
Triggering method with change in object property
I have an array of dataframe objects (columns of a larger dataframe) that I am passing into the Dataframe_Builder_Update class. I am able to successfully update the date and associated calculation of ...
0
votes
1
answer
43
views
How to Include All Properties in GridView Even if They're Absent in Some Objects?
I'm using PowerShell to parse XML content and display the results in a grid view. Here's the code I'm using:
$content = @"
<root>
<obj>
<name>John</name>
...
-1
votes
2
answers
44
views
Adding objects as properties of a master object with Javascript
I have a master object, for example:
MasterObj = {
property1: ...
method1: ...
}
and multiple other objects:
obj1 = {
properties and methods...
},
obj2 = {
properties and methods...
}
I need to make ...
0
votes
0
answers
53
views
ChromeDevTools SetVariableValue: how change object property? array cell?
How to change an object property using the ChromeDevTools?
I ran the following code on nodejs with debugger support:
function test() {
var obj = {
"my_prop": 1
}
return ...
0
votes
1
answer
43
views
Adding values from a JavaScript object as classes on an element
In JavaScript, how would I take the values of an object and add each one as a separate class on an element in the DOM?
For instance, let's say I have this object:
const METADATA = {
foo: 'test1',
...
1
vote
2
answers
89
views
Is there a Javascript/Lodash function to check if an object is missing ANY properties?
I want to check a javascript object to see if any of it's properties are missing without checking each property individually.
I can use "hasownproperty" or do if/else statements to check if ...
0
votes
1
answer
369
views
How to make a method, that accepts an input, into a property of a class object?
The issue I've encountered here, is that I am currently trying to make an object that has a method as a property. I was able to get it to work on public static void methods, but not methods that ...
0
votes
1
answer
183
views
Adding a property that is hidden unless it has a value
I'm adding a class related to software packages. Here is a barebones version for the purposes of this question:
class Package {
$Name; $Latest; $Prerelease
[string]ToString(){ return $this....
1
vote
1
answer
235
views
How can I read the name of a thread in a C# application?
I'm working on a multithreaded application, written in C#.
I would like to verify if a thread is already running or not.
You might think "How easy can that be?", but there seems to be a ...
0
votes
1
answer
20
views
I've been trying this code for a for loop inplementing an array into it
const jonas = {
firstName: 'Jonas',
lastName: 'Billing',
age: 2037-1991,
job: 'teacher',
friends: ['Michael', 'Peter', 'Steven']
};
const types = [];
for (let i = 0; i < jonas.length; i++) {
...
0
votes
0
answers
25
views
How can I access an object property inside the object while inside a function in the property without a getter?(javascript)
I have this code where I want all my code to be inside one main object without exeptions:
var inputs = [];
var Ivh = {
addInput: (input, display, message, regex) => {
inputs.push([input, ...
2
votes
3
answers
59
views
Neater way to create an object
I am creating an object with values from an api response. Is there a neater way to do this?
My code:
const variables = {
name: result.data.data.table.name,
org: the_org,
val1: result.data....
0
votes
2
answers
2k
views
TypeError: object of type 'property' has no len()
I have this code of a class that contains a list _offers of custom Offer objects. For this list I created a property to allow access to it:
class OffersManager:
_offers: list[Offer] = []
...
0
votes
0
answers
33
views
Why can't I access a property of an object in a loaded array of objects in typescript?
So, I cannot wrap my mind around this problem...
Basically, I have some variables and a constructor in a class:
currentUser: UserModel | null = null;
currentServer: ServerModel | null = null;
...
1
vote
0
answers
15
views
Typescript: map nested object properties to string [duplicate]
I am wondering if it is possible to create a type which maps properties of an object to a string where if a certain property value is an object himself, it is added to the string preceded by a dot. ...
0
votes
0
answers
67
views
Creating Events in Powershell
The Task:
I'm writing a script that makes changes to an AD Object (user account) in sequential order:
Name change
Group add
Demographics change
Manager name added
Add email address
The problem:
I ...
2
votes
1
answer
708
views
typescript access object property: Element implicitly has an 'any' type
I'm working on a codebase where I need to access a value from the step property.
interface Car {
name: string;
age: number;
color: string;
step: {
something: {
onea:...
-3
votes
2
answers
167
views
System.NullReferenceException Object reference not set to an instance of an object (List) [duplicate]
public List<Faculty> Faculties {get;set;}
List<Faculty> faculties = FacultiesManager.Faculties;
Faculties.Add(something);
how can i interact with the object list
2
votes
2
answers
925
views
A way to catch any change of an object with properties
I have a simple program that's supposed to capture any change of object A. When it does detect a change, it will write down the stringified object into file A.
Now the most obvious approach would be ...
0
votes
2
answers
96
views
I want to filter an array of objects through an object property
I´m new to Javascript, I´m trying to filter an array of objects through one of the object properties (to get the object that has the biggest value of said property. How would I go about to doing that?
...
3
votes
2
answers
577
views
Is there a way of accessing the properties of an object in java by using a string to represent the property's name, just like in JavaScript?
In JavaScript you can access a property of an object in two ways:
object.property
object["property"]
In Java, I am only aware of the first way. Is there a way to access a Java object's ...
0
votes
1
answer
224
views
How can I add Nested Object List Properties to an existing Object
I'm trying to figure out how I can add an object list property to an existing object, which also has a list object property. I have 3 classes as FirstList, SecondList, and ThirdList with an Id and ...
0
votes
1
answer
48
views
While using the Object.defineProperties in JavaScript I am getting as ' undefined' on newly defined property .How to fix it..?
const object1 = {
firstName : 'Shashidhar',
lastName : 'B M ',
rollNo : 5678,
rank : 23456
}
Object.defineProperties(object1,{
property1 : {
results : 'selected'
}
});
...
0
votes
1
answer
64
views
Count number of filled properties of object with objects
I need to make a percentage of fields filled in a form, which is stored in an object.
For that I need the number of filled fields and the total number of fields.
Let's say I've this object (7 ...
0
votes
1
answer
2k
views
PHP check if object exists and get it's property in one line
I am wondering if there is in php7.3/php7.4 somehow possible to check inline if and object exists and if yes then get it's property like nullsafe operator. Like this it returns error:
$object = null;
...
3
votes
2
answers
6k
views
Typescript - How to access a variable object property from a variable object
I'm having some difficulty trying to write a function that takes two inputs:
The name of an object
The name of a property
and prints the value of that property for that object. However, the objects ...
0
votes
2
answers
43
views
Deleting an object from an array and changing one of its properties simultaneously - javascript
I have this array of objects:
const flights = [
{ id: 00, to: "New York", from: "Barcelona", cost: 700, scale: false },
{ id: 01, to: "Los Angeles", from: "...
-1
votes
1
answer
44
views
Javascript - How using a variable for object property
Im very beginner in javascript, i would like to use all variable created on each object property :
let title = "Les Miserables";
let resume = "Blabla blaaabla...";
let autor = &...
0
votes
4
answers
315
views
How to get first properties of each object in an array of objects?
const combinations = [{rolledOnes: true, scoredOnes:false},
{rolledTwos: true, scoredTwos:false}];
I am fairly new to Javascript. So, my actual array is larger than this. I ...
-1
votes
1
answer
74
views
Adding values to object inside array not working - cannot set property of undefined
I am trying to transform a JSON that was build from a CSV file
[
{
"id_familia": 15,
"relacao": 1,
"occupation": "RESPONSAVEL",
&...
0
votes
2
answers
742
views
How to dynamically handle changes in a JSON object name that may change regularly, when building C# class to deserialize the JSON? [closed]
my predicament is that I have to deserialize some JSON files provided by my company's software eng department, for me to use in a production environment, however some revisions of the JSON files have ...
0
votes
2
answers
38
views
Replacing similar items of an array from the objects value
There's an object below named cricket mania consisting of net runs and points scored by different countries. I am trying to write a code in JS to sort the teams according to their Points first, and if ...
0
votes
1
answer
235
views
Get object properties from a generic object in java
I have a method to get properties from a generic object in c# below. How can I get the same in java?
public string GetProperty<T>(T obj)
{
var s = string.Empty;
...
0
votes
1
answer
162
views
Match elements of properties in objects in JavaScript
I've been trying to compare all the series from my objects with the corresponding genre. I managed to display them but I'm practically writing the same code three times, while I'm sure there is a ...
0
votes
2
answers
339
views
How do I make the child object not inherit a method or property from the parent object?
I'm creating a child object using class, but I don't want it to inherit some properties and methods from the parent object.
I want to know if there is any way to do this.
my code:
class Player {
#...
2
votes
1
answer
69
views
Using methods to select an object's property and assign it a value creates an error
I am trying to write a method that based on some value, returns a property that I'd like to define in another method. However, I am having a strange 'Uncaught ReferenceError: Invalid left-hand side in ...
0
votes
0
answers
36
views
How does this function know to search for my input?
So probably a silly question. How does this function know to replace "obj" with whatever object I put in, and replace "checkProp" with whatever property I put in?
I'm pretty much ...
0
votes
0
answers
16
views
Is there a way to stop edits of specific properties in an object? [duplicate]
I am building out a shopping cart component and have a function to add new items. My object structure looks like so:
productsArray = [{
"item": {
"id": 001,
"...
2
votes
0
answers
317
views
Transform JavaScript object by clearing, adding and removing properties
Here are the instructions for what I am supposed to do:
Implement a function accepting 2 arguments: state and actions. The
function should change the state basing on the given actions
array.
state ...
0
votes
0
answers
62
views
Why does Object.defineProperty make a property invisible when logged?
I'm trying to understand why using Object.defineProperty makes a property not visible when the object is logged in the console.
For instance:
let foo = {};
Object.defineProperty(foo, "a", {
...
0
votes
0
answers
131
views
Convert a string chain of property accessor to give the actual value (JavaScript)
My question is quiet simple.
I have an object that looks like that:
const person = {
name: 'David',
locations: [
{
country: 'Belgium',
},
{
country: 'France',
...
0
votes
2
answers
291
views
assign property to object in array
I know there are a lot of questions like this and this is probably a duplicate, but be sure, i tried every single solution provided to these questions and none of them worked for me.
Here's the thing:
...
0
votes
1
answer
33
views
How can I change property value of an object after executing eventListener
So, I wanna change property used from 0 to 1 when it's used, but when I do
function x() {
const array = [{
name: x,
surname: y,
...