Call (877) SITE-OPT (748-3678)

Code: Use String Constant Macros

Chapter 8 - Ajax Optimization

For example, if you have a number of alert( ) invocations in your program, like this:

alert("An error has occurred");

you could set a global variable, like this:

msg="An error has occurred";

to serve as a string constant and then replace the repeated strings in the various alert( ) calls as follows:


You can even use this macro expansion idea for partial strings. For example, use the earlier string constant that we set and modify it:

alert(msg+": email address is required");
Copyright © 2002-2018 Website Optimization, LLC. All Rights Reserved - Free website speed test - Privacy Policy
Last modified: February 19, 2009.

Follow us on: Twitter, Google+, Facebook, Linked In