Linked Questions

1904 votes
33 answers
1.5m views

How do I check if an object has a specific property in JavaScript? Consider: x = {'key': 1}; if ( x.hasOwnProperty('key') ) { //Do this } Is there another way to do it?
sheats's user avatar
  • 34.9k
2 votes
1 answer
1k views

I have used like below example to check property exists on an object. const payload ={payment:0} if(payload && payload.payment){ console.log(payload.payment) }else{ console.log('Issue') }...
user2473015's user avatar
  • 1,452
0 votes
1 answer
191 views

I have an object like this: let column = ["A", "B", "C", "D"] validation: { type: ... id: ... // and possible report that could exists or not ...
Jack23's user avatar
  • 1,396
0 votes
0 answers
74 views

Variable br must consist only of bool values. Which have been gotten by looping through the first array. state ={ nonRelated: this.props.non_related.value, 1:true, 2:true, 3:false, ...
Sth's user avatar
  • 542
49 votes
9 answers
169k views

I'm new to using react.js, and am trying to write a re-usable component that has an optional property passed to it. In the component, that optional property pulls data from a db using meteor, then I ...
bgmaster's user avatar
  • 2,353
49 votes
1 answer
31k views

The new method Object.hasOwn() returns a boolean indicating whether the specified object has the indicated property as its own property but so does Object.prototype.hasOwnProperty(), what is the ...
Ran Turner's user avatar
  • 18.7k
20 votes
3 answers
6k views

I have this code : user.findOne( { 'email' : email }, function( err, User ) { if ( err ) { return done(err); } ...
Yahya Ayash Luqman's user avatar
13 votes
2 answers
8k views

I am trying to access a certain member in a JavaScript object. In order to do this, I need to try out a couple of key values. For example, Object['text/html'] which will give me an export link for a ...
Nafiul Islam's user avatar
  • 82.9k
2 votes
3 answers
12k views

I have an array of objects that I want to filter based on the name of the key for those objects. In this particular case I know that there will be one key/value pair for each element in the array. ...
Muirik's user avatar
  • 6,349
3 votes
4 answers
15k views

I have a list of objects in the following way: obj = [ { a:[1,2,3] }, { b:[4,5,6] }, { c:[7,8,9] } ] How do I get the correspoding array for a key using javascript? Eg. For b, I would get [4,5,6]. I ...
Adirtha1704's user avatar
3 votes
2 answers
3k views

I am having the JSON array of objects like below, let data = [ { "node":[ { "name":"aaaaa", "count":"2", } ] ...
kalaiyarasi M's user avatar
0 votes
1 answer
2k views

So, similar to my my previous question here (I was unsure whether to make a new question or edit the old one), I managed to sucessfully parse the body JSON response using the code seen below. However ...
uknj's user avatar
  • 89
-1 votes
1 answer
2k views

(Using javascript) I've seen some answers saying dictionary.has("key") will evaluate to true or false based on if the key is in the dictionary. For some reason, this hasn't worked for me at ...
that_javascript_girl's user avatar
0 votes
2 answers
1k views

I have list of objects response.tasks: {userLastName: ', srCreationDate: '', idNumber: '', firstName: ', insStartDate: null, …} and I want to know if I have some properties for userLastName it will be ...
Uri Perkal's user avatar
-2 votes
2 answers
1k views

New learner here, I'm stuck on a practice question for a course and I'm not sure what it's asking me to do here. The problem is as follows: Write a function that takes a user object, which represents ...
Charl's user avatar
  • 1

15 30 50 per page