hasOwnProperty (String - JavaScript)

Checks whether a string has a specified property.

Defined in

String (Standard - JavaScript)

Syntax

hasOwnProperty(property:string) : boolean
Parameters Description
property The name of a property.
Return value Description
boolean True if the string has the property; otherwise false.

Examples

This example tests a String object for three properties.
cities = new String("Paris   Moscow   Tokyo");
return "constructor = " + cities.hasOwnProperty("constructor")
+ "\nlength = " + cities.hasOwnProperty("length")
+ "\nprototype = " + cities.hasOwnProperty("prototype")