Questions tagged [object-properties]
117 questions
1
vote
1 answer
Check if property exists, if it does build off of the property
I have the following PHP code:
$alignments = new StdClass();
if ($query->num_rows > 0)
{
foreach($query->result() as $row){
$alignments->{$row->table_id} = new StdClass();
…

dennismonsewicz
- 25,132
- 33
- 116
- 189
1
vote
1 answer
Special symbols on objects names dont let me navigate trough objects/arrays in php
Right now, im using drupal for making a site. Im modifying the drupals user module, because i need to make a custom layout for the profile page.
Unfortenly im having issues for accessing trough the array.
all the data of the profile is on an array…

EgEm
- 13
- 3
0
votes
2 answers
Object property name as function argument with ensured type in Typescript
How to write definition of type in function argument which is one of object properties with same type?
For example I have object:
type Article = {
name: string;
quantity: number;
priceNet: number;
priceGross: number;
};
and want to write…

Piotr Witkoś
- 334
- 3
- 10
0
votes
1 answer
Accessing An Object Property Wrapped in an Array
This one is a two parter. Firstly I have a form with a bunch of values defaultly assigned and I'm displaying a chart.js chart.
Ideally I would like the user to be able to submit those values and then update the values in the chart by calling a…
user21297781
0
votes
1 answer
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'
…

SBM
- 17
- 4
0
votes
1 answer
Property of a self instance in Django Models?
recently i have created a model for storing some states in my DB. It's very simple i only store id and name.
class PayType(models.Model):
id = models.AutoField(primary_key=True)
name = models.CharField(max_length=200)
class Meta:
…

maizorin97
- 5
- 5
0
votes
2 answers
How do I access a property of a conditional type with generics?
The following code fails as TypeScript:
const exampleFn = function(
whatToProcess: AttributeName extends 'attributeA' ? {attributeA: string} : {attributeB: string},
attributeName:…

WBT
- 2,249
- 3
- 28
- 40
0
votes
1 answer
'Object property set inside decorator function doesn't persist as expected.'
I've only been learning to use JavaScript for 4 months, so please let me know if there is something obvious I am missing.
In this problem, I am writing 2 functions,
One is the inner (non-critical) work function. It just adds 2 numbers.
The second…

AZ ZA
- 13
- 2
0
votes
1 answer
Where should I put this object property/attribute
I am creating a testing program. The three main objects I have right now are Tests, Questions, and Answers. I have three tables in the database, tests, questions and answers and a FK from questions to tests and a foreign key from answers to…

jworrin
- 825
- 1
- 8
- 20
0
votes
1 answer
How to modify an object
I am trying to "push" information inside the object based on certain conditions.
I need to insert/push/assign more information within the property "materials" but I am not sure how to do this.
This is the structure of my current object:
const…

Joaquin Pagliettini
- 29
- 1
- 7
0
votes
3 answers
JAVASCRIPT: Getting NaN result after calling function in document.write()
I'm trying to get the bornYear as the result with the below code but getting NaN as a result.
function person(name, age){
this.name = name;
this.age = age;
this.yearOfBirth = bornYear;
}
function bornYear(){
return 2020 -…

Kunal Goel
- 3
- 1
0
votes
1 answer
Using Same Object Property between Multiple Classes
I tried to use the same object property between multiple classes, but I got a warning that the same object property has been set multiple times as follows, can you please let me know what is wrong with that and how to solve it? Does this restrict…

Avv
- 429
- 4
- 17
0
votes
2 answers
Why we cant use normal for loop to print javascript object?
I am learning JavaScript, so today I came across to know that to print or get object properties the for..in loop is used. but i got confuse here because I haven't seen the for..in loop before. so I encountered a query that why we cant use for loop…

DevashishBhor
- 7
- 5
0
votes
4 answers
Javascript copy properties inside an object
I have an object as below;
record = {
prop1: 'X',
prop2: 'Y',
prop3: 'Z'
}
Now I want all these properties to be copied to a "row" attribute inside "record". So, it should look like;
record = {
row: {
prop1: 'X',
…

copenndthagen
- 49,230
- 102
- 290
- 442
0
votes
4 answers
How to delete property?
class C():
@property
def x(self):
return 0
delattr(C(), 'x')
>>> AttributeError: can't delete attribute
I'm aware del C.x works, but this deletes the class's property; can a class instance's property be deleted?

OverLordGoldDragon
- 1
- 9
- 53
- 101