Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 276 trang
THÔNG TIN TÀI LIỆU
Thông tin cơ bản
Định dạng
Số trang
276
Dung lượng
4,73 MB
Nội dung
[...]... of information above and beyond the solutions in this book, and a lot of fun and experienced JavaScript developers hang out there It’s a good way to learn new tricks, get questions answered in a hurry, and just have a good time TheSitePoint Newsletters In addition to books like this one, SitePoint publishes free email newsletters including TheSitePoint Tribune, TheSitePoint Tech Times, andThe SitePoint. .. one The Corrections and Typos page on the book’s web site will provide the latest information about known typographical and code errors, and will offer necessary updates for new releases of browsers and related standards.1 TheSitePoint Forums If you’d like to communicate with other web developers about this book, you should join SitePoint s online community.2 TheJavaScript forum,3 in particular, offers... returns another 10 TheArt & Science OfJavaScript anonymous function to the onclick handler The outer function forms a closure, a concept that’s discussed in more detail in Chapter 5 Here’s the revised code: a.onclick = function (that) { return function () { } }(this); The brackets at the end ofthe main function cause it to be executed as soon as it is loaded by the browser (rather than when the click... Structurally, a table is a collection of rows, which in turn are collections of cells There is no tangible HTML element 2 TheArt & Science OfJavaScript that represents a column of cells the only elements that come close are colgroup and col, but they serve only as aids in styling the table In terms of actual structure, there are no columns Let’s take a closer look at the simple table shown in Figure 1.1... class="footnote">*Stated in millions of dollars Each set of tags tells the browser to begin a new row in our table The and tags inside them represent header and data cells, respectively Though the cells are arranged vertically in HTML, and almost look like columns of data, they’re actually rendered horizontally as part of a row Notice also that the rows are grouped within either or a ... debugging, and profiling tool It takes the traditionally awkward task ofJavaScript debugging and optimization, and makes it intuitive and fun Here, Michael Mahemoff reveals tons of pro-level tips and hidden treasures to give you new insight into this indispensable development tool Chapter 5: Metaprogramming with JavaScript Here, Dan Webb takes us on a journey into the mechanics of theJavaScript language... will check the item either before or after the current item in the array If there’s an item in that position, our attempt will return true This will allow us to check whether the value ofthe current item is greater than that of its neighbor If it is, we need to swap the two We also set the variable unsorted to true, as we’ve just made a change in the order of our dataset, and ensure that the item’s... modern web application really stand out is usually implemented with JavaScript If CSS was the darling of the early 2000s, JavaScript has since well and truly taken over the throne In this book, we’ve assembled a team of experts in their field—a veritable who’s who ofJavaScript developers—to help you take your JavaScript skills to the next level From creating impressive mashups and stunning, dynamic graphics... rep resents one step forward in the inner loop The black arrow next to the numbers shows the progress ofthe inner loop (as does the “i=0” on top of each column) The red, curved arrows represent a swap that has taken place between the current item andthe next one Note how the outer loop goes over the entire dataset once more at the end, to make sure that there aren’t any more swaps to perform We’d like... Before we start looping over our data, we need to set up a couple of variables The dir para meter’s only valid values, 1 and -1, represent ascending and descending order respectively Checking for the value of dir, we set the start and end points for our inner loop accordingly When dir is ascending, we’ll start at zero and end at the array’s length; when it’s descending, we’ll start at the array’s . join SitePoint s online community. 2 The JavaScript forum, 3 in particular, offers an abundance of information above and beyond the solutions in this book, and a lot of fun and experienced JavaScript. in the park. The birds were singing and the kids were all back at school.</p> If the code may be found in the book’s code archive, the name of the file will appear at the top of the. and profiling tool. It takes the traditionally awkward task of JavaScript debugging and optimization, and makes it intuitive and fun. Here, Michael Mahemoff reveals tons of pro-level tips and