Javascript Level 5 - Objects

Object Property: *.length (To count the length of the variable - number of character including the spaces)

<html>
<body>
<script type="text/javascript">

var word = "Hello Job";
document.write (word.length);

</script>
</body>
</html>


Object Method: *.toUpperCase( ) (Change all the characters to Uppercase)


<html>
<body>
<script type="text/javascript">

var word = "Hello Job";
document.write (word.toUpperCase( ));

</script>
</body>
</html>



Object Method: *.bold( )


<html>
<body>
<script type="text/javascript">

var word = "Hello Job";
document.write (word.toUpperCase( ));

</script>
</body>
</html>


Object Method: *.strike( )


<html>
<body>
<script type="text/javascript">

var word = "Hello Job";
document.write (word.strike( ));

</script>
</body>
</html>


Object Method: *.fontcolor( )


<html>
<body>
<script type="text/javascript">

var word = "Hello Job";
document.write (word.fontcolor ( "Red" ));

</script>
</body>
</html>



indexOf ( finds the first occurrence of the part of the string that you are looking for)


<html>
<body>
<script type="text/javascript">

var word = "Hello Job. How are you today?";
document.write (word.indexOf("Job")); 

</script>
</body>
</html>

//You will get the answer 6 as Job is the 6 character stating from 0
//If you get -1, this means that they can't find it. -1 means false.


match (tells javascript to search and find a match) -eg. your password is not correct


<html>
<body>
<script type="text/javascript">

var word = "Hello Job";
document.write (word.match(Job));

</script>
</body>
</html>


//The output will be "Job"
//"null" means there is no match



replace (find all the Job and replace with Tim)


<html>
<body>
<script type="text/javascript">

var word = "Hello Job";
document.write (word.replace(/Job/, "Tim" ));

</script>
</body>
</html>