Training Guide: Programming in HTML5 with JavaScript and CSS3 Ebook
Answers CHAPTER 5 259 C. Incorrect: The <col> element must be inside a <colgroup> element. D. Incorrect: The <hid ...
...
261 Chapter 6 Essential JavaScript and jQuery CHAPTER 6 Essential JavaScript and jQuery T he flexibility of JavaScript is amazin ...
262 CHAPTER 6 Essential JavaScript and jQuery Lesson 1: Creating JavaScript objects In JavaScript, everything is an object. Stri ...
Lesson 1: Creating JavaScript objects CHAPTER 6 263 an object and owned by the object. A method is a function that is defined on ...
264 CHAPTER 6 Essential JavaScript and jQuery var car2 = { year: 2010, make: 'BMW', model: 'Z4', getInfo: function () { return ' ...
Lesson 1: Creating JavaScript objects CHAPTER 6 265 FIGURE 6-1 he JavaScript object literal testT Creating dynamic objects by us ...
266 CHAPTER 6 Essential JavaScript and jQuery After the object is created, you can dynamically add properties to it that hold th ...
Lesson 1: Creating JavaScript objects CHAPTER 6 267 make = theMake; model = theModel; getInfo = function () { return 'Vehicle: ' ...
268 CHAPTER 6 Essential JavaScript and jQuery FIGURE 6-2 he failing test assertions after a second vehicle is usedT To solve the ...
Lesson 1: Creating JavaScript objects CHAPTER 6 269 Remember that the this keyword references the object that owns the current c ...
270 CHAPTER 6 Essential JavaScript and jQuery FIGURE 6-3 uccessful first assertion and failed second assertionS Consider the fol ...
Lesson 1: Creating JavaScript objects CHAPTER 6 271 you expected? Is that what you wanted? You can see that in some scenarios, t ...
272 CHAPTER 6 Essential JavaScript and jQuery this.make = theMake; this.model = theModel; } Vehicle.prototype.getInfo = function ...
Lesson 1: Creating JavaScript objects CHAPTER 6 273 Now that you have a functioning class, change the prototype to see whether i ...
274 CHAPTER 6 Essential JavaScript and jQuery replace individual instance functions and you don’t mind making your data public, ...
Lesson 1: Creating JavaScript objects CHAPTER 6 275 This test is successful, so replace the getInfo method and add more tests. T ...
276 CHAPTER 6 Essential JavaScript and jQuery FIGURE 6 -7 he use of getters to expose read-only data as a good compromiseT Imple ...
Lesson 1: Creating JavaScript objects CHAPTER 6 277 var myApp = {}; myApp.vehicleCount = 5; myApp.vehicles = new Array(); myApp. ...
278 CHAPTER 6 Essential JavaScript and jQuery An IIFE (pronounced iffy) is an anonymous function expression that has a set of pa ...
«
10
11
12
13
14
15
16
17
18
19
»
Free download pdf