Details

JavaScript and Open Data


JavaScript and Open Data


1. Aufl.

von: Robert Jeansoulin

139,99 €

Verlag: Wiley
Format: PDF
Veröffentl.: 21.06.2018
ISBN/EAN: 9781119527305
Sprache: englisch
Anzahl Seiten: 272

DRM-geschütztes eBook, Sie benötigen z.B. Adobe Digital Editions und eine Adobe ID zum Lesen.

Beschreibungen

<p>This book will teach you how to take advantage of the JavaScript language to process data provided on the Internet. </p> <p>Much attention is given to the main JavaScript backbone: prototype based objects, and functional capabilities, while common features (loops, etc.) are summarized in a few cheat-sheets. Only operational features are detailed through the coding of several applications -the second and largest part of the book-, on free-access datasets (e.g. World Bank). It includes: cartography (SVG or API's based), data-sheets access (via Ajax or Jsonp), video data and post-synchronization, and animation examples.</p>
<p>Introduction xiii</p> <p><b>Part 1. Core JavaScript 1</b></p> <p><b>Introduction to Part 1 3</b></p> <p><b>Chapter 1. Variables: Declaration, Definition and Type 5</b></p> <p>1.1. Declarations of functions and variables 6</p> <p>1.1.1. The different declaration keywords 6</p> <p>1.1.2. Lexical scope and definition of a variable according to declaration mode: var, let, const 9</p> <p>1.1.3. Comments (important improvements carried over by ES6) 11</p> <p>1.1.4. General conclusion about the variable declarations in JavaScript 11</p> <p>1.1.5. Naming variables and functions: best practices 14</p> <p>1.2. Variable definition, initialization and typing in JavaScript 15</p> <p>1.2.1. Variables initialization and definition 15</p> <p>1.2.2. Types 15</p> <p>1.2.3. How to use the type “undefined” and the value undefined 17</p> <p><b>Chapter 2. Controls: Booleans, Branch and Loops 19</b></p> <p>2.1. Truth values and boolean operators 19</p> <p>2.1.1. Boolean operators: “!” (not), “&&” (and), “||” (or) 19</p> <p>2.1.2. Relational operators: >, <, >=, <= 20</p> <p>2.1.3. Comparison operators: = =, != (simple) or = = =, != = (strict) 20</p> <p>2.2. Conditional instructions: branch test, loop test 21</p> <p>2.2.1. Conditional instructions: if ... else, if ... else if ... else 21</p> <p>2.2.2. Ternary conditional operator 21</p> <p>2.2.3. Instruction “switch” 22</p> <p>2.2.4. Classical iteration loop: instruction “for” 22</p> <p>2.2.5. Repeat under condition: instructions “while”, and “do..while” 23</p> <p>2.2.6. Implicit casting of values “undefined” and “null” in boolean context 23</p> <p>2.2.7. Short-cut evaluation: tips for the uncertain definitions 24</p> <p>2.2.8. Exception handling 24</p> <p><b>Chapter 3. Data: Numbers and Strings 27</b></p> <p>3.1. Handling numbers 28</p> <p>3.1.1. Literal notation of type “number” variables 28</p> <p>3.1.2. Arithmetic operators 29</p> <p>3.1.3. Math operations using the methods of the object Math 30</p> <p>3.1.4. Evaluation in the “numerical context” versus “boolean context” 32</p> <p>3.2. Handling character strings 32</p> <p>3.2.1. Literal notation of strings 32</p> <p>3.2.2. Backtick syntax, or template syntax, introduced by ES6 33</p> <p>3.2.3. Concatenation operator 34</p> <p>3.2.4. Resolving polymorphism issues with operator + in numerical or string context 34</p> <p>3.2.5. Behavior of the relational and equality operators 35</p> <p>3.2.6. Various facets of string-related issues in a sample application 35</p> <p>3.3. The String.prototype methods 37</p> <p>3.3.1. The need for preprocessing before comparison 37</p> <p>3.3.2. Handling partial comparisons 38</p> <p>3.3.3. Methods for handling strings 39</p> <p>3.3.4. Regular expressions 41</p> <p>3.3.5. Evaluation and uses 42</p> <p>3.3.6. Some examples of useful patterns 42</p> <p>3.3.7. General syntax of a regular expression 43</p> <p>3.3.8. Combining RegExp and String.prototype methods 44</p> <p><b>Chapter 4. Objects and Prototypes 45</b></p> <p>4.1. Introduction 45</p> <p>4.2. The objects: concepts versus named entities 46</p> <p>4.3. Object literal notation in JavaScript 47</p> <p>4.3.1. Syntax for “object literal”: 47</p> <p>4.3.2. Important warnings about writing JavaScript object notation 48</p> <p>4.3.3. The object literal first use: to define an object type variable 49</p> <p>4.3.4. The object literal second use: data notation in JSON format 49</p> <p>4.3.5. Accessing the individual properties of an object 50</p> <p>4.3.6. Notation syntax evolution with ES6 51</p> <p>4.4. The builtin methods of Object and Object.prototype 51</p> <p>4.4.1. The methods of Object, Object.prototype, and JSON 51</p> <p>4.4.2. Create an object and specify its properties 53</p> <p>4.4.3. Syntax and usage of the “descriptor” property 53</p> <p>4.4.4. Listing the properties of an object, analyzing a literal 54</p> <p>4.5. Basics of the “prototypal approach” in JavaScript 56</p> <p>4.5.1. JavaScript object's fundamental relation: “has prototype” 57</p> <p>4.5.2. Role of the prototypes and inheritance mechanism 58</p> <p>4.5.3. Object construction: the “literal approach” 60</p> <p>4.5.4. Object construction: the “prototypal approach” 61</p> <p>4.5.5. The pattern “assign/create” 62</p> <p>4.5.6. Object construction: the “classical approach” 63</p> <p>4.6. Comparing “prototypal” and “classical” approaches 64</p> <p>4.6.1. Simulating a class hierarchy in JavaScript 65</p> <p>4.6.2. Summing up what we learned so far 68</p> <p><b>Chapter 5. Arrays 71</b></p> <p>5.1. Handling arrays: creation and access to its elements 72</p> <p>5.1.1. Creating an array with the array literal notation 72</p> <p>5.1.2. Checking if a variable is an array 72</p> <p>5.1.3. The length property, the index count 73</p> <p>5.1.4. Accessing individual values in an array: the indices 74</p> <p>5.2. Methods of the object Array and Array.prototype 74</p> <p>5.2.1. The “Mutators” family 75</p> <p>5.2.2. The “Accessors” family 77</p> <p>5.2.3. The “Iteration” family 78</p> <p>5.2.4. Iterating over the elements of an array 78</p> <p>5.2.5. Iteration without a loop, with Array/Array.prototype methods 79</p> <p>5.2.6. Chaining array methods 81</p> <p>5.2.7. Arrays and the arrow function syntax 82</p> <p>5.2.8. The “Iterables” 83</p> <p>5.3. Array of arrays (multidimensional array) 83</p> <p>5.3.1. Frameworks proposing an “augmented Array.prototype” 85</p> <p><b>Chapter 6. Functions 87</b></p> <p>6.1. General syntax of a JavaScript function 88</p> <p>6.1.1. Name 88</p> <p>6.1.2. Parameters 88</p> <p>6.1.3. Return 89</p> <p>6.1.4. Function code block and scope 89</p> <p>6.1.5. Creating functions 89</p> <p>6.2. Invoking a function with operator (.) 90</p> <p>6.2.1. The three facets of the “parentheses operator” in a function context 91</p> <p>6.3. Choosing function declaration versus function expression 92</p> <p>6.4. Arguments 93</p> <p>6.4.1. The arguments are passed by value 93</p> <p>6.4.2. The inner object “arguments” 94</p> <p>6.5. Scope: global scope, function scopes and block scopes 94</p> <p>6.5.1. Vocabulary: lexical scope and “namespace” 94</p> <p>6.5.2. Wrapping-up and warnings 98</p> <p>6.6. Function “closures” 101</p> <p>6.6.1. Saving the value of a free variable in a given context 102</p> <p>6.6.2. Creating a list of functions linked to an array of data 103</p> <p>6.6.3. Currying”: breaking down a function into 1-parameter functions 106</p> <p>6.6.4. Compositing functions from an array of functions 107</p> <p>6.7. Immediately invocable functions: IIFE 109</p> <p>6.7.1. Creating a “namespace”, or a named library, with an IIFE 109</p> <p>6.8. The methods of Function.prototype 110</p> <p>6.8.1. Function.prototype.call() and .apply(), and pronoun 'this' 112</p> <p>6.8.2. Function.prototype.bind() 112</p> <p>6.9. Built-in functions 113</p> <p>6.10. Closure and IIFE cheat-sheet 114</p> <p><b>Chapter 7. From Signs to Patterns 117</b></p> <p>7.1. Reserved words 118</p> <p>7.2. The pronoun “this” 119</p> <p>7.2.1. The many ways to link the pronoun “this” 119</p> <p>7.2.2. How to explicitly bind the pronoun? 121</p> <p>7.3. Operator: new 121</p> <p>7.4. Punctuation signs 122</p> <p>7.5. JavaScript usual design patterns 123</p> <p>7.5.1. Programming idioms 124</p> <p>7.5.2. Creational pattern: “Assign/Create Combo” 125</p> <p>7.5.3. Structural pattern: singleton or namespace pattern 127</p> <p>7.5.4. Another structural pattern: the Decorator pattern 128</p> <p>7.5.5. Behavioral pattern: the observer or publish/subscribe pattern 130</p> <p>7.6. Metaprogramming with ES6 131</p> <p>7.6.1. “Reflection” by “Symbols” 131</p> <p>7.6.2. New tool for measuring code performance 131</p> <p><b>Part 2. Client-Side JavaScript 133</b></p> <p><b>Introduction to Part 2 135</b></p> <p><b>Chapter 8. JavaScript in the Web Page 137</b></p> <p>8.1. Ecosystem of the web page: the HTML sequence 137</p> <p>8.1.1. Structure and semantics/layout and presentation 137</p> <p>8.1.2. Reminder about HTML5 tags 138</p> <p>8.2. Building the web page DOM: the layout engine 140</p> <p>8.2.1. DOM tree built by the layout engine: selecting nodes via CSS 141</p> <p>8.2.2. CSS rules and relationship with JavaScript selection methods 142</p> <p>8.3. Dynamic behavior of the web page: the script engine 143</p> <p>8.4. Interface with the DOM 145</p> <p>8.4.1. DOM interface 1: selecting elements 145</p> <p>8.4.2. DOM interface 2: reading/writing/creating an element 146</p> <p>8.4.3. Methods for HTML DOM document and element prototypes 148</p> <p>8.5. The events in client side JavaScript 150</p> <p>8.5.1. The browser event loop 150</p> <p>8.5.2. Handling DOM events 151</p> <p>8.6. Interacting with the DOM: to link elements/events 153</p> <p>8.6.1. Waiting for the DOM 153</p> <p>8.6.2. Example: to build an HTML list 153</p> <p>8.6.3. Using events: modifying attributes and class names of an element. 154</p> <p>8.6.4. Dispatching events, creating a CustomEvent 155</p> <p><b>Chapter 9. Graphic and Multimedia Tools 157</b></p> <p>9.1. To draw in the web page 157</p> <p>9.1.1. The elements and 158</p> <p>9.1.2. 2D curve plot 158</p> <p>9.2. SVG language 161</p> <p>9.3. Handling time in graphics animation 163</p> <p>9.3.1. Methods setTimeout, setInterval, requestAnimationFrame 163</p> <p>9.3.2. Performance considerations, generator functions 165</p> <p>9.4. Data persistence between client sessions 166</p> <p>9.4.1. Http cookies 166</p> <p>9.4.2. Local storages 167</p> <p>9.5. Note about “JavaScript frameworks” (jQuery, d3, etc.) 168</p> <p>9.5.1. A few words about jQuery 168</p> <p>9.5.2. Recommendation 169</p> <p><b>Chapter 10. AJAX Technology (Asynchrony) 171</b></p> <p>10.1. Architecture for client–server data exchange 171</p> <p>10.1.1. The object XMLHttpRequest 172</p> <p>10.1.2. Using XMLHttpRequest: several steps 172</p> <p>10.2. Remarks about HTTP 173</p> <p>10.3. “Promises” and asynchronous programming 173</p> <p>10.3.1. Example: promisifying XMLHttpRequest 174</p> <p>10.3.2. Chaining promises 175</p> <p>10.3.3. Parallel processing of several promises 175</p> <p>10.3.4. Fetch: the promise to fetch AJAX 176</p> <p>10.3.5. About the “Same Origin Policy” 177</p> <p>10.4. The exchange format: JSON 177</p> <p>10.4.1. A very useful application of JSON: converting data from a spreadsheet 178</p> <p>10.4.2. Exporting spreadsheet data into JSON format 179</p> <p>10.4.3. Differences between JSON and the Javascript object Notation 182</p> <p>10.5. JavaScript Object Notation with Padding 184</p> <p>10.6. A parallel JavaScript: the “worker” 185</p> <p><b>Part 3. Applications 187</b></p> <p><b>Introduction to Part 3 189</b></p> <p><b>Chapter 11. Chronological Data 191</b></p> <p>11.1. Accessing a JSON file via Ajax 191</p> <p>11.1.1. Quick presentation of the Quandl API 191</p> <p>11.1.2. Processing an example with promises 192</p> <p>11.2. Using open source graphic libraries 195</p> <p>11.2.1. Plot multiple data series against the same time axis 195</p> <p>11.2.2. Dynamic plot: simulating time evolution 197</p> <p><b>Chapter 12. Relational Data 199</b></p> <p>12.1. Aggregating tabulated JSON data 199</p> <p>12.1.1. lectoral data: administrative breakdown, political breakdown 200</p> <p>12.1.2. Aggregating data along the spatial dimension: votes by circonscription 203</p> <p>12.1.3. Aggregating data along the affiliations dimension: labels by candidate 205</p> <p>12.2. Joining data: multiple JSON files 207</p> <p>12.2.1. Advantage of the flexibility brought by the prototypal approach 207</p> <p>12.2.2. Coding the join on the electoral application 208</p> <p>12.3. Postprocessing: analysis 210</p> <p>12.3.1. Analyzing the affiliations 210</p> <p>12.4. The role of promises 211</p> <p>12.4.1. Performance considerations with the electoral application 213</p> <p>12.5. Using Google Gantt chart for a graphic visualization 214</p> <p><b>Chapter 13. Cartographic Data 217</b></p> <p>13.1. Cartographic application: using cartographic libraries 217</p> <p>13.1.1. Preparation of the map 219</p> <p>13.1.2. Creating a layer of markers 220</p> <p>13.1.3. Interacting and selecting features 222</p> <p>13.2. SVG-based cartography 222</p> <p>13.2.1. Description of the application 223</p> <p>13.2.2. Embedding the whole SVG document by direct copy 224</p> <p>13.2.3. Embedding the SVG code, element by element 225</p> <p>13.2.4. Joining relational data and SVG data 225</p> <p>13.2.5. Processing the combined information 226</p> <p>13.3. Getting coordinates from Wikipedia pages 227</p> <p><b>Chapter 14. Data Served by JSONP 229</b></p> <p>14.1. Serving RSS feeds through <i>Yahoo Query Language</i> 229</p> <p>14.2. Serving shared spreadsheets through Google spreadsheets 231</p> <p>14.2.1. Client-side code: HTML and script of the callback function 231</p> <p>14.2.2. Server-side code under the GoogleScript global object 232</p> <p>14.3. Serving images and their metadata through the Flickr API 233</p> <p>Bibliography 235</p> <p>Index 239</p>
<strong>Robert Jeansoulin</strong>, CNRS, France.

Diese Produkte könnten Sie auch interessieren:

Strategies to the Prediction, Mitigation and Management of Product Obsolescence
Strategies to the Prediction, Mitigation and Management of Product Obsolescence
von: Bjoern Bartels, Ulrich Ermel, Peter Sandborn, Michael G. Pecht
PDF ebook
116,99 €