tailieunhanh - JavaScript Bible, Gold Edition part 12

JavaScript Bible, Gold Edition part 12. This book will bring programmers and non-technical professionals, including casual programmers and scripters, painlessly up to speed on all aspects of mastering JavaScript. Key topics include programming fundamentals, JavaScript language elements and how to use them effectively, and how to easily and efficiently add powerful new functionality to HTML documents and Java applets. | CD-40 Part II JavaScript Tutorial Testing Evaluation in Navigator You can begin experimenting with the way JavaScript evaluates expressions with the help of The Evaluator Jr. seen in the following figure an HTML page you can find on the companion CD-ROM. I introduce the Senior version in Chapter 13. Enter any JavaScript expression into the top text box and either press Enter Return or click the Evaluate button. The Evaluator Jr. has 26 variables lowercase a through z predefined for you. Therefore you can assign values to variables test comparison operators and even do math here. Using the age variable examples from earlier in this chapter type each of the following statements into the upper text box and observe how each expression evaluates in the Results field. Be sure to observe case-sensitivity in your entries. a 45 a b a 15 b a b a b To start over click the Refresh Reload button. Data Type Conversions I mentioned earlier that the type of data in an expression can trip up some script operations if the expected components of the operation are not of the right type. JavaScript tries its best to perform internal conversions to head off such problems but JavaScript cannot read your mind. If your intentions differ from the way JavaScript treats the values you won t get the results you expect. Chapter 6 Programming Fundamentals Part I CD-41 A case in point is adding numbers that may be in the form of text strings. In a simple arithmetic statement that adds two numbers together you get the expected result 3 3 result 6 But if one of those numbers is a string JavaScript leans toward converting the other value to a string thus turning the plus sign s action from arithmetic addition to joining strings. Therefore in the statement 3 3 result 33 the string-ness of the second value prevails over the entire operation. The first value is automatically converted to a string and the result joins the two strings. Try this yourself in The Evaluator Jr. If I take this progression one

TỪ KHÓA LIÊN QUAN
crossorigin="anonymous">
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.