Using the Function object for defining new functions is not recommended because it is by far the least efficient of the three alternatives. Whare the Function object is actually useful is that it allows us to add methods to all our functions that allow us to change the way that the functions work. You might […]
- The Basics
- Basic DOM
- DOM Tables
- DOM Forms
- Server Interaction
- Regular Expressions
- Error Handling
- Using Functions
- Object Oriented
- Extend Objects
- Homework Questions
- The Bad Bits
Yet another thing we may need to convert text into is an array with each array element containing the same number of characters. This is relatively easy where we want just one character per element but adding a new method makes it far easier when the chunk size is more than one character.
If we are processing plain text then we may have situations where there is a maximum number of characters that are allowed on each line. We can easily add a method that will add line breaks to the text such that we don’t split a line in the middle of a word.
Phone numbers are a bit different from other numbers in that a leading zero needs to be retained. Different parts of the world apply different formatting to phone numbers but for the purpose of saving the numbers we can save space by removing any such formatting (we can add it back when we display the […]
We have already looked at how to convert text strings into dates. Another “type” conversion that we might need is one that converts text into numbers remebering that we need to strip out any formatting in order that the numbers can be used for calculations.
This site is © copyright Stephen Chapman - Felgall Pty Ltd 2011-2013.