The Facebook Platform   
    Home  |   Learn AJAX  |   Forum  |    Register  |    Submit Resource  |   Submit Article   |   Contact Us
 

AJAX Tips

Home AJAX Tips

String Extensions in MS Ajax

Category: AJAX Tips   |   Comments (0)

Microsoft can be considered late in its adoption of JavaScript. Unfortunately, IE has become a "unique" form of browser in a bad way because it has some troubles in the past in dealing with the programming language. But the software giant has adjusted to the demand of their users and they are providing sufficient support.


Sponsored Links
 

 


It's important for every developer to realize that Microsoft Ajax has subtle differences compared to popular JavaScript coding. Because of this difference, developers have to make sure they are coding also for IE aside from coding for other browsers.


One of the differences that should be noted about Microsoft Ajax is their string type extensions. The following are the unique syntax that will be implemented through Microsoft Ajax:


String.endsWith


This is a very straightforward string type extension because its sole purpose is to determine the compatibility of the file added by users or the system. The syntax is added with a suffix which is also the determining factor. If the entered data matches, the function will naturally return with "true".


String.format


This string extension can have two distinct functions depending on the variable added.


String.format() - by default, this function is used to make some changes in the string entered by users. This is often used on dates, names and other variables and the string is used to properly determine the value of the entered date.


String.format(argument) - the argument simply contains an object or a number of objects that will instruct the function on how to interpret the data entered.


String.localeFormat


This is practically the same compared to the previous function. The "locale" is actually to limit the application of string.format but they have the same behavior. In fact, it doesn't even matter if you use this function or the previous String.Format.


String.startsWith


This function is the complete opposite of String.endsWith(). As already indicated, the previous function determines the compatibility of the file based on the suffix. This function deals with the start of the object. Like the previous function, it will return true if there is a match with the indicated variable.


String.trim, String.trimEnd and String.trimStart


One of the best string type extensions from Microsoft Ajax is their function dedicated to "cleaning" the code. These commands will remove the white spaces in the coding. The name will suggest where the white spaces will be trimmed. For example, String.trimEnd removes the whitespaces at the end of the objects.


But implementation of trims should be done with extreme caution. Although whitespaces can be considered bane in the application, it is sometimes added with the specific purpose of clarification. This is very rare but it can sometimes happen in the application. For that reason, it is recommended to implement the specific trims (trimEnd and trimStart) rather than using a function that will sweep the application of whitespaces.



Sponsored Links
 

 

These are the string type extensions in Microsoft Ajax. Notice the difference on how they are written so that they should work perfectly in any application. It's another learning requirement but a must for every Ajax and JavaScript developer.



Read Next: Working with HTML DOM


 
Post Your Comment
Members - Please Click here Login
Your Name:*
e-mail ID:(required for notification)*
Image Verification:
 
 Subscribe    

Post Your Comment via FaceBook

Connect with Facebook



 
Comments
 
 
 
 

Sponsored Links

 

Copyright © 2005 - 2010 AjaxWith.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape