JavaScript index Property
Description
The index property reflects a number (n) such that (n�1) is the character where the first match starts.
If myArray is the result of a string's match() method call, myArray.input.charAt(myArray.index) is the first character of the first match.
The index property only applies to arrays generated by a match() method call of a string or an exec() method call of a regular expression.
Syntax
object.index
Example 1
In this example we will show how to use the constructor property:
<script>
var test = new Date();
if (test.constructor == Array)
{
document.write("This is an Array");
}
if (test.constructor == Boolean)
{
document.write("This is a Boolean");
}
if (test.constructor == Date)
{
document.write("This is a Date");
}
if (test.constructor == String)
{
document.write("This is a String");
}
</script>
Try it Yourself »
Example 2
In this example we will show how to use the constructor property:
<script>
function employee(name, jobtitle, born)
{
this.name = name;
this.jobtitle = jobtitle;
this.born = born;
}
var fred = new employee("Fred Flintstone", "Caveman", 1970);
document.write(fred.constructor);
</script>
Try it Yourself »