JavaScript in Operator Last Updated : 12 Jul, 2025 Comments Improve Suggest changes Like Article Like Report JavaScript in operator is an inbuilt operator which is used to check whether a particular property exists in an object or not. It returns a boolean value true if the specified property is in an object, otherwise, it returns false. Syntax:prop in objectParameters: prop: This parameter holds the string or symbol that represents a property name or array index.object: This parameter is an Object that is to be checked whether it contains the prop.Return value: This method returns a boolean value. The value true is returned if the specified property is found in an object, else it returns false. Example 1: Below is an example of the in-operator. JavaScript function gfg() { // Illustration of in operator const array = ['geeks', 'for', 'geeks'] // Output of the indexed number console.log(0 in array); // Output of the Value console.log('for' in array); // output of the Array property console.log('length' in array); } gfg(); Outputtrue false true Example 2: This example shows the use of the in operator in Javascript. JavaScript // Illustration of in operator const array = ['geeksforgeeks', 'geeksfor', 'geeks', 'geeks1'] // Output of the indexed number console.log(0 in array) console.log(2 in array) console.log(5 in array) // Output of the Value console.log('for' in array) console.log('geeksforgeeks' in array) // output of the Array property console.log('length' in array) Outputtrue true false false false true Example 3: This example shows the use of the in operator in Javascript. JavaScript // Illustration of in operator const object = { val1: 'Geeksforgeeks', val2: 'Javascript', val3: 'operator', val4: 'in' }; console.log('val1' in object); delete object.val1; console.log('val1' in object); if ('val1' in object === false) { object.val1 = 'GEEKSFORGEEKS'; } console.log(object.val1); Outputtrue false GEEKSFORGEEKS Supported Browsers:Google ChromeFirefoxOperaSafariEdgeInternet ExplorerWe have a complete list of Javascript Operators, to check those please go through the Javascript Operators Complete Reference article. Comment More info S shubhamsingh10 Follow Improve Article Tags : JavaScript Web Technologies javascript-operators Explore JavaScript BasicsIntroduction to JavaScript4 min readVariables and Datatypes in JavaScript6 min readJavaScript Operators5 min readControl Statements in JavaScript4 min readArray & StringJavaScript Arrays7 min readJavaScript Array Methods7 min readJavaScript Strings6 min readJavaScript String Methods9 min readFunction & ObjectFunctions in JavaScript5 min readJavaScript Function Expression3 min readFunction Overloading in JavaScript4 min readObjects in Javascript4 min readJavaScript Object Constructors4 min readOOPObject Oriented Programming in JavaScript3 min readClasses and Objects in JavaScript4 min readWhat Are Access Modifiers In JavaScript ?5 min readJavaScript Constructor Method7 min readAsynchronous JavaScriptAsynchronous JavaScript2 min readJavaScript Callbacks4 min readJavaScript Promise4 min readEvent Loop in JavaScript4 min readAsync and Await in JavaScript2 min readException HandlingJavascript Error and Exceptional Handling6 min readJavaScript Errors Throw and Try to Catch2 min readHow to create custom errors in JavaScript ?2 min readJavaScript TypeError - Invalid Array.prototype.sort argument1 min readDOMHTML DOM (Document Object Model)9 min readHow to select DOM Elements in JavaScript ?3 min readJavaScript Custom Events4 min readJavaScript addEventListener() with Examples9 min readAdvanced TopicsClosure in JavaScript4 min readJavaScript Hoisting6 min readJavascript Scope3 min readJavaScript Higher Order Functions7 min readDebugging in JavaScript4 min read Like