Secrets of the JavaScript Ninja pdf

364 1.3K 3
Secrets of the JavaScript Ninja pdf

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

[...]... some developers’ poor initial reaction to JavaScript may be that most developers are introduced to JavaScript in the browser So rather than reacting to JavaScript, The Language, they may be recoiling from the JavaScript bindings to the DOM API And the DOM API… well, let’s just say that it isn’t going to win any Friendliest API of the Year awards But that’s not JavaScript s fault Before we learn about... queue (a FIFO list, more on that later) as they occur, and the browser dispatches these events by invoking any handlers that have been established for them Because these events happen at unpredictable times and in an unpredictable order, we say that the handling of the events, and therefore the invocation of their handling functions, is asynchronous The types of events that can occur include:  Browser... first-class objects  How the browser invokes function  Declaring functions  The secrets of how functions are invoked  The context within a function You might have been somewhat surprised, upon turning to this first page of the part of this book dedicated to JavaScript fundamentals, to see that the topic of discussion is to be functions rather than objects We’ll certainly be paying plenty of attention to... pull it off, we need not only a mastery of the JavaScript language, but a thorough knowledge of the browsers, along with their quirks and inconsistencies, and a good grounding in accepted best practices While JavaScript development can certainly be challenging, there are those brave souls who have already gone down this torturous route: the developers of JavaScript libraries We’ll be distilling the knowledge... written to the console and be browsed immediately or at a later time without impeding the normal flow of the program – something not possible with alert() For example, if we wanted to know what the value of a variable named x was at a certain point in the code, we might write: console.log(x); If we were to assume that the value of x is 213, then the result of executing this statement in the Chrome... (If the notation used to create the function looks odd to you, be assured that we’ll be making it crystal clear in section 3.2.) Unobtrusive JavaScript This approach of assigning a function, named or otherwise, to the onload property of the window instance may not be the way that you are used to setting up a load handler You may be more accustomed to using the onload attribute of the tag Either... we also have the problem of determining if our code works in all the browsers that we choose to support We'll further discuss the problem of cross-browser development in-depth when we look at cross-browser strategies in chapter 11, but for now, it's vital that the importance of testing be emphasized and testing strategies defined, as we'll be using these strategies throughout the rest of the book In... objects (particularly in chapter 6), but when it comes down to brass tacks, the main difference between writing JavaScript code like the average Joe (or Jill) and writing it like a JavaScript Ninja, is understand JavaScript as a functional language The level of the sophistication of all the code that you will ever write in JavaScript hinges upon this realization If you’re reading this book, you’re... markup, CSS, or JavaScript as we can without disrupting the intent of the test case The more that we remove, the greater the likelihood that the test case will only be influenced by the specific code that we are trying to test • Independence – our tests should execute in isolation We must strive to not make the results from one test be dependent upon another We should break tests down into their smallest... JSUnit JSUnit is a port of the popular Java JUnit testing framework to JavaScript While it's still one of the most popular JavaScript unit testing frameworks around, JSUnit is also one of the oldest (both in terms of the code base age and quality) The framework hasn't been updated much recently, so for something that's known to work with all modern browsers, JSUnit may not be the best choice More information . the choices of those in the decision- making process, taking into account factors such as the skill of the developers, the needs of the market, and other. multiple considerations, the primary of which are:  The market share of the browser  The amount of effort necessary to support the browser Figure 1.2

Ngày đăng: 22/03/2014, 16:20

Từ khóa liên quan

Mục lục

  • Secrets of the JavaScript Ninja MEAP v10

  • Copyright

  • Table of Contents

  • Chapter 1: Enter the ninja

    • 1.1 Our key JavaScript libraries

    • 1.2 Understanding the JavaScript Language

    • 1.3 Cross-browser considerations

    • 1.4 Best practices

      • 1.4.1 Best practice: testing

      • 1.4.2 Best practice: performance analysis

      • 1.5 Summary

      • Chapter 2: Testing and debugging

        • Debugging Code

          • 2.1.1 Logging

          • 2.1.2 Breakpoints

          • 2.2 Test generation

          • 2.3 Testing frameworks

            • 2.3.1 QUnit

            • 2.3.2 YUITest

            • 2.3.3 JSUnit

            • 2.4 The Fundamentals of a Test Suite

              • 2.4.1 The assertion

              • 2.4.2 Test groups

              • 2.4.3 Asynchronous Testing

              • 2.5 Summary

              • Chapter 3: Functions are fundamental

                • 3.1 What’s with the functional difference?

                  • 3.1.1 Why is JavaScript’s functional nature important?

Tài liệu cùng người dùng

Tài liệu liên quan