Below is the example of the in operator.
// Illustration of in operator
const array = [
// Output of the indexed number
// Output of the Value
// output of the Array property
true false true
prop in object
Parameters: This function accepts the following parameter as mentioned above and described below:
- prop: This parameter holds the string or symbol that represents a property name or array index.
- object: This parameter is an Object which to be checked whether it contains the prop.
Return value: This method returns an boolean values :
- true: The value true is returned if the specified property is found in an object.
- false: The value false is returned if the specified property is not found in an object.
> true > true > false > false > false > true
> true > false > "GEEKSFORGEEKS"
- Google Chrome
- Internet Explorer
- Ternary operator vs Null coalescing operator in PHP
- Why overriding both the global new operator and the class-specific operator is not ambiguous?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.