JavaScript string object

JavaScript string object we can use with its different properties and methods to get various string formats and string types. We will discuss with some examples for better understanding.
Let us first declare a new string object like this.
<script type="text/javascript">
my_string= new String("Welcome to plus2net.com");
</script> 

Length property to get the length of the string

It gives the total length of the string including blank spaces present in a string.
document.write(my_string.length); 
Output:  23 

Making the string Bold

document.write(my_string.bold());

Declaring the font size of the string

document.write(my_string.fontsize(6));

Making the string blink ( not work in IE )

document.write(my_string.blink());

Making TT type font with fixed

document.write(my_string.fixed());

Making the font color of the string

document.write(my_string.fontcolor("blue"));

Changing to Italic font

document.write(my_string.italics());

Adding a link to the string by link

document.write(my_string.link("https://www.plus2net.com"));

Making the font style strike out

Demo script using strike property
document.write(my_string.strike());

Getting a substring with start and end points

document.write(my_string.substring(10,15));

Making sub script

document.write(my_string.sub());
JavaScript String Reference Lowercase to Upper case by toUpperCase() method
Subscribe to our YouTube Channel here


Subscribe

* indicates required
Subscribe to plus2net

    plus2net.com







    Post your comments , suggestion , error , requirements etc here




    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2024 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer