·  JavaScript – Syntax – Keywords – in

 

- Info:

  - in keyword returns true if the specified property name can be found in the specified object.

 

- Example:

  - Create D\Temp\JavaScript\Test.html

 

    Test.html

    <script>

   

      //OBJECTS.

      john = {name:"John", age:25};

      document.write("name"   in john);  //true

      document.write("weight" in john);  //false

   

      //ARRAYS.

      pople = ["John", "Jill"];

      document.write(0        in pople);   //true   Index exists.

      document.write(2        in pople);   //false  Index doesn't exist.

      document.write("Jill"   in pople);   //false  Looks for indexes and not values.

      document.write("length" in pople);   //true   length is an Array property.

      

    </script>