Tham khảo sách 'javascript bible_ chapter 35', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | Global Functions and Statements In addition to all the objects and other language constructs described in the preceding chapters of this reference part of the book several language items need to be treated on a global scale. These items apply to no particular objects or any object and can be used anywhere in a script. If you ve read earlier chapters you have been introduced to many of these functions and statements. This chapter is presented as a convenient place to highlight these all-important items that are otherwise easily forgotten. This chapter covers the following functions and statements Functions Statements eval and . comment escape var isNaN Number parseFloat parseInt String unescape unwatch watch In This Chapter Converting strings into object references Converting strings to numbers for math Adding comments to scripts Very often the discussions point to examples in earlier chapters that demonstrate the item in context. Functions Global functions are not tied to the document object model. Instead they typically let you convert data from one type to another type. 728 Part III JavaScript Object and Language Reference eval string Returns Object reference. Nav2 Nav3 Nav4 IE3 J1 IE3 J2 IE4 J3 Compatibility Expression evaluation as you are probably well aware by now is an important concept to grasp in scripting with JavaScript and programming in general . An expression evaluates to some value. But occasionally you need to force an additional evaluation on an expression to receive the desired results. The eval function acts on a string value to force an evaluation of that string expression. Perhaps the most common application of the eval function is to convert a string version of an object reference to a genuine object reference. For example in an effort to create a Dynamic HTML script that accommodates the different ways that Microsoft and Netscape reference positionable objects see Chapter 41 one technique is to assemble references out of the comparable pieces