Change Language


Follow Navioo On Twitter

in

Returns true if the specified property name can be found in the specified object.

Syntax

propertyNameOrValue in objectName

Example

// Arrays
trees=new Array("redwood","bay","cedar","oak","maple")
0 in trees        // returns true
3 in trees        // returns true
6 in trees        // returns false
"bay" in trees    // returns false (you must specify the index number,
                  // not the value at that index)
"length" in trees // returns true (length is an Array property)

// Predefined objects
"PI" in Math          // returns true
myString=new String("coral")
"length" in myString  // returns true

// Custom objects
mycar = {make:"Honda",model:"Accord",year:1998}
"make" in mycar  // returns true
"model" in mycar // returns true 
text_javascript Navioo_docs

Ajax Javascript feed

↑ Grab this Headline Animator