Skip to content
Advertisement

Checking if a key exists in a JS object

I have the following JavaScript object:

JavaScript

Is there a way to check if a key exists in the array, similar to this?

JavaScript

does not work.

Do I have to iterate through the obj like this?

JavaScript

Advertisement

Answer

Use the in operator:

JavaScript

Sidenote: What you got there, is actually no jQuery object, but just a plain JavaScript Object.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement