1. Trang chủ
  2. » Công Nghệ Thông Tin

Manning Early Access Program Secrets of the JavaScript Ninja version 10 ppt

364 3K 0

Đ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

Thông tin cơ bản

Định dạng
Số trang 364
Dung lượng 8,84 MB

Nội dung

[...]... right down to their DNA NOTE Another factor that plays into 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... 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... 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... (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... going to execute as the result of an event (in other words as part of the “Process event” box) It’s important to note that whatever browser mechanism is putting the events onto the queue is external to this event loop model The processing necessary to determine when events have occurred and to push them onto the event queue does not participate in the thread that’s handling the events Manning Publications... 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... testing works 2.4.1 The assertion The core of a unit-testing framework is its assertion method; usually named assert() This method usually takes a value – an expression whose premise is asserted – and a description that describes the purpose of the assertion If the value evaluates to true, in other words is “truth-y”, then the assertion passes, otherwise it is considered a failure The associated message... 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 . MEAP Edition Manning Early Access Program Secrets of the JavaScript Ninja version 10 Copyright 2012 Manning Publications. 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

Ngày đăng: 14/03/2014, 09:20

TỪ KHÓA LIÊN QUAN