What is the usage of in operator in JavaScript?

The operator is used in JavaScript to check whether a property is in an object or not.


You can try to run the following code to learn how to use in operator in JavaScript −

Live Demo

<!DOCTYPE html>
         var emp = {name:"Amit", subject:"Java"};
         document.write("name" in emp);
         document.write("subject" in emp);
         document.write("MAX_VALUE" in Number);
         document.write("MIN" in Number);