JavaScript
  Home arrow JavaScript arrow Page 3 - JavaScript Objects: Strings
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
JAVASCRIPT

JavaScript Objects: Strings
By: James Payne
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 3
    2008-01-14

    Table of Contents:
  • JavaScript Objects: Strings
  • Length Property
  • Prototype
  • The Anchor() Method
  • The Big() Method
  • The Bold() Method

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    JavaScript Objects: Strings - Prototype


    (Page 3 of 6 )

    The Prototype property allows you to add properties and methods to your objects. Remember our superhero, Studman? Well he complained that we weren't giving him a salary. And being hot is hard work, so how could we refuse?



    <html>

    <body>


    <script type="text/javascript">


    function superhero(firstname,lastname,superpower)

    {

    this.firstname=firstname

    this.lastname=lastname

    this.superpower=superpower

    }

    var studman=new superhero("Stud","Man","Looks Hot")


    superhero.prototype.salary=null


    studman.salary=50000


    document.write(studman.salary)


    </script>


    </body>

    </html>

    The above code creates the superhero object and assigns it properties. Having been given an ultimatum by Studman himself, the program then adds another property, Salary, to the Studman object, and assigns it a value of 50000. Not bad for a guy who can buy things with his looks.

    String Object Methods

    There are far more String Object methods than there are properties. In fact we may well need another tutorial to cover all of them. However, we will give it a shot and get through as many as possible here.

    Here is a table displaying them in all their glory:

    Method

    Description

    anchor()

    Creates an HTML anchor

    big()

    Displays a string in a big font

    blink()

    Displays a blinking string

    bold()

    Displays a string in bold

    charAt()

    Returns the character at a specified position

    charCodeAt()

    Returns the Unicode of the character at a specified position

    concat()

    Joins two or more strings

    fixed()

    Displays a string as teletype text

    fontcolor()

    Displays a string in a specified color

    fontsize()

    Displays a string in a specified size

    fromCharCode()

    Takes the specified Unicode values and returns a string

    indexOf()

    Returns the position of the first occurrence of a specified string value in a string

    italics()

    Displays a string in italic

    lastIndexOf()

    Returns the position of the last occurrence of a specified string value, searching backwards from the specified position in a string

    link()

    Displays a string as a hyperlink

    match()

    Searches for a specified value in a string

    replace()

    Replaces some characters with some other characters in a string

    search()

    Searches a string for a specified value

    slice()

    Extracts a part of a string and returns the extracted part in a new string

    small()

    Displays a string in a small font

    split()

    Splits a string into an array of strings

    strike()

    Displays a string with a strikethrough

    sub()

    Displays a string as subscript

    substr()

    Extracts a specified number of characters in a string, from a start index

    substring()

    Extracts the characters in a string between two specified indices

    sup()

    Displays a string as superscript

    toLowerCase()

    Displays a string in lowercase letters

    toUpperCase()

    Displays a string in uppercase letters

    toSource()

    Represents the source code of an object

    valueOf()

    Returns the primitive value of a String object

    More JavaScript Articles
    More By James Payne


       · Thanks for stopping by. In this article we talk about JavaScript String Objects,...
     

    JAVASCRIPT ARTICLES

    - Validating Digits and Dates with jQuery`s Va...
    - Validating Ranges, Emails, and URLs with jQu...
    - More Uses for the jQuery Tooltip Plug-in`s b...
    - Building Image-Based Tooltips with the jQuer...
    - Using the jQuery Tooltip Plug-in`s bodyHandl...
    - Using Rangelength, Min and Max with the Vali...
    - Using Minlength and Maxlength with the Valid...
    - Modifying Tooltip Coordinates with the jQuer...
    - Applying a Fade Out Effect with the jQuery T...
    - Tracking Mouse Movements with the jQuery Too...
    - Checking Online Forms with the Validator jQu...
    - Nested JavaScript Functions as Objects
    - The jQuery Tooltip Plug-in
    - Active Client Pages at the Server
    - ACP Tab Web Page







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
    Stay green...Green IT