TAILIEUCHUNG - the book of javascript 2nd edition p9

Chương trình nguồn JavaScript được thông dịch trong trang HTML sau khi toàn bộ trang được load nhưng trước khi trang được hiển thị. | Consider the code in Figure 18-6. function getName var first_name prompt What s your first name var last_name prompt What s your last name var the_name first_name last_name function theGreeting o debugger var the_name getName if the_name Dave Thau alert Howdy partner else alert Ahoy polloi Figure 18-6 Starting the debugger As before we suspect that something funny is going on with getName . In this case rather than putting in an alert or using logging we invoke the JavaScript debugger in o. This stops the JavaScript program and makes the JavaScript debugger window look like Figure 18-7. The debugger line appeared within theGreeting so the Local Variables section of the debugger shows you what it knows about the function. Initially it knows that there is one variable the_name and that it has no value the value is void . Figure 18-7 After o has been executed 372 Chapter 18 After I click the Step Into button a couple of times to get into getName then fill in some prompts the debugger in Figure 18-8 shows that first_name and last_name are set correctly. Figure 18-8 Examining variables first_name and last_name look correct I click the Step Into button a few more times until I ve exited getName and I see in Figure 18-9 that for some reason the_name is still void. From this I can deduce that the value is not getting passed out of the getName function. Figure 18-9 Examining variables the_name looks incorrect Debugging JavaScript and Ajax 373 In this simple example the complexity of a full-blown debugger such as Venkman is unnecessary. However with complicated functions being able to step through the JavaScript one line at a time and see the values of the variables at every step can cut down debugging time immensely. If you d like to learn more about how to use Venkman you can find an excellent tutorial at http code learning_venkman. The Venkman debugger is by far the easiest JavaScript debugger to use and is itself a reason to download Firefox. If you .

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã 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.