Nicht aus der Schweiz? Besuchen Sie lehmanns.de
JavaScript Cookbook - Shelly Powers

JavaScript Cookbook

Programming the Web

(Autor)

Buch | Softcover
628 Seiten
2015 | 2nd Revised edition
O'Reilly Media (Verlag)
978-1-4919-0188-5 (ISBN)
CHF 62,80 inkl. MwSt
  • Titel ist leider vergriffen;
    keine Neuauflage
  • Artikel merken
Why reinvent the wheel every time you run into a problem with JavaScript?

This cookbook is chock-full of code recipes that address common programming tasks, as well as techniques for building web apps that work in any browser. Just copy and paste the code samples into your project - you'll get the job done faster and learn more about JavaScript in the process.
Problem solving with JavaScript is a lot trickier now that its use has expanded considerably in size, scope, and complexity. This cookbook has your back, with recipes for common tasks across the JavaScript world, whether you’re working in the browser, the server, or a mobile environment. Each recipe includes reusable code and practical advice for tackling JavaScript objects, Node, Ajax, JSON, data persistence, graphical and media applications, complex frameworks, modular JavaScript, APIs, and many related technologies.

Aimed at people who have some experience with JavaScript, the first part covers traditional uses of JavaScript, along with new ideas and improved functionality. The second part dives into the server, mobile development, and a plethora of leading-edge tools. You’ll save time—and learn more about JavaScript in the process.

Topics include:
Classic JavaScript:
  • Arrays, functions, and the JavaScript Object
  • Accessing the user interface
  • Testing and accessibility
  • Creating and using JavaScript libraries
  • Client-server communication with Ajax
  • Rich, interactive web effects

JavaScript, All Blown Up:
  • New ECMAScript standard objects
  • Using Node on the server
  • Modularizing and managing JavaScript
  • Complex JavaScript frameworks
  • Advanced client-server communications
  • Visualizations and client-server graphics
  • Mobile application development

Shelley Powers has been working with, and writing about, web technologies--from the first release of JavaScript to the latest graphics and design tools--for more than 12 years. Her recent O'Reilly books have covered the semantic web, Ajax, JavaScript, and web graphics. She's an avid amateur photographer and web development aficionado, who enjoys applying her latest experiments on her many web sites.

Classic JavaScript
Chapter 1The JavaScript Not-So-Simple Building Blocks
Differentiating Between a JavaScript Object, Primitive, and Literal
Extracting a List from a String
Checking for an Existing, Nonempty String
Inserting Special Characters
Replacing Patterns with New Strings
Finding and Highlighting All Instances of a Pattern
Swapping Words in a String Using Capturing Parentheses
Replacing HTML Tags with Named Entities
Converting an ISO 8601 Formatted Date to a Date Object Acceptable Format
Using Function Closures with Timers
Tracking Elapsed Time
Converting a Decimal to a Hexadecimal Value
Summing All Numbers in a Table Column
Converting Between Degrees and Radians
Find the Radius and Center of a Circle to Fit Within a Page Element
Calculating the Length of a Circular Arc
Using ES6 String Extras Without Leaving Users in the Dirt
Chapter 2JavaScript Arrays
Searching Through an Array
Flattening a Two-Dimensional Array with concat() and apply()
Removing or Replacing Array Elements
Extracting a Portion of an Array
Applying a Function Against Each Array Element
Traversing the Results from querySelectorAll() with forEach() and call()
Applying a Function to Every Element in an Array and Returning a New Array
Creating a Filtered Array
Validating Array Contents
Using an Associative Array to Store Form Element Names and Values
Using a Destructuring Assignment to Simplify Code
Chapter 3Functions: The JavaScript Building Blocks
Placing Your Function and Hoisting
Passing a Function As an Argument to Another Function
Implementing a Recursive Algorithm
Preventing Code Blocking with a Timer and a Callback
Creating a Function That Remembers Its State
Converting Function Arguments into an Array
Reducing Redundancy by Using a Partial Application
Improving Application Performance with Memoization (Caching Calculations)
Using an Anonymous Function to Wrap Global Variables
Providing a Default Parameter
Chapter 4The Malleable JavaScript Object
Keeping Object Members Private
Using Prototype to Create Objects
Inheriting an Object’s Functionality
Extending an Object by Defining a New Property
Preventing Object Extensibility
Preventing Any Changes to an Object
Namespacing Your JavaScript Objects
Rediscovering this with Prototype.bind
Chaining Your Object’s Methods
Chapter 5JavaScript and Directly Accessing the User Interface
Accessing a Given Element and Finding Its Parent and Child Elements
Accessing All Images in the Web Page
Discovering All Images in Articles Using the Selectors API
Setting an Element’s Style Attribute
Applying a Striped Theme to an Unordered List
Finding All Elements That Share an Attribute
Inserting a New Paragraph
Adding Text to a New Paragraph
Deleting Rows from an HTML Table
Adding a Page Overlay
Creating Collapsible Form Sections
Hiding Page Sections
Creating Hover-Based Pop-Up Info Windows
Displaying a Flash of Color to Signal an Action
Chapter 6Preliminary Testing and Accessibility
Cleaning Up Your Code with JSHint
Unit Testing Your Code with QUnit
Testing Your Application in Various Environments
Performance Testing Different Coding Techniques
Highlighting Errors Accessibly
Creating an Accessible Automatically Updated Region
Chapter 7Creating and Using JavaScript Libraries
Finding the Perfect Library
Testing for Features with Modernizr.load
Going Beyond the Math Object’s Capability
Finding the Number of Days Between Two Dates
Using an External Library: Building on the jQuery Framework
Using a jQuery Plugin
Handling Keyboard Shortcuts with Mousetrap
Utilizing the Utility Library Underscore
Packaging Your Code
Adding Support for Private Data Members
Minify Your Library
Hosting Your Library
Serving Code from a CDN
Convert Your Library to a jQuery Plug-in
Safely Combining Several Libraries in Your Applications
Chapter 8Simplified Client-Server Communication and Data
Handling an XML Document Returned via an Ajax Call
Extracting Pertinent Information from an XML Tree
Parsing and Automatically Modifying JSON
Converting an Object to a Filtered/Transformed String with JSON
Making an Ajax Request to Another Domain (Using JSONP)
Processing JSON from an Ajax Request
Populating a Selection List from the Server
Using a Timer to Automatically Update the Page with Fresh Data
Chapter 9Creating Media Rich, Interactive Web Effects
Creating a Dynamic Line Chart in Canvas
Adding JavaScript to SVG
Accessing SVG from Web Page Script
Integrating SVG and the Canvas Element in HTML
Running a Routine When an Audio File Begins Playing
Controlling Video from JavaScript with the video Element
Adding Filter Effects to Video via Canvas
JavaScript, All Blown Up
Chapter 10The New ECMAScript Standard Objects
Using let in Your Browser Application
Creating a Collection of Non-Duplicated Values
Creating Unique Key/Value Pairs with Uniquely Different Keys
Creating Absolutely Unique Object Property Keys
Iterating Through Tasks Made Easy
Creating Functions that Gracefully Yield
Implementing Just-in-Time Object Behavioral Modifications with Proxies
Creating a True Class and Extending It (with a Little Help from Traceur)
Using Promises for Efficient Asynchronous Processing
Chapter 11Node: JavaScript on the Server
Responding to a Simple Browser Request
Serving Up Formatted Data
Reading and Writing File Data
Using let and Other ES 6 Additions in Node
Interactively Trying Out Node Code Snippets with REPL
Getting Input from the Terminal
Working with Node Timers and Understanding the Node Event Loop
Managing Callback Hell
Accessing Command-Line Functionality Within a Node Application
Running Node and Apache on the Same Port
Keeping a Node Instance Up and Running
Monitoring Application Changes and Restarting
Screen Scraping with Request
Creating a Command-Line Utility with Help From Commander
Chapter 12Modularizing and Managing JavaScript
Loading Scripts with a Script Loader
Loading Scripts Asynchronously the HTML5 Way
Converting Your JavaScript to AMD and RequireJS
Using RequireJS with jQuery or Another Library
Loading and Using Dojo Modules
Installing and Maintaining Node Modules with npm
Searching for a Specific Node Module via npm
Converting Your Library into a Node Module
Taking Your Code Across All Module Environments
Creating an Installable Node Module
Packaging and Managing Your Client-Side Dependencies with Bower
Compiling Node.js Modules for Use in the Browser with Browserify
Unit Testing Your Node Modules
Running Tasks with Grunt
Chapter 13Fun with APIs
Accessing JSON-Formatted Data via a RESTful API
Creating a RESTFul API with Restify
Enabling a Mobile-Like Notification in the Desktop Browser
Loading a File Locally in the Browser
Creating a Mini E-Pub Reader Using Web Workers and the File API
Exploring Google Maps and Other APIS
Accessing Twitter’s API from a Node Application
Chapter 14JavaScript Frameworks
Using the Express-Generator to Generate an Express Site
Converting a Generated Express Site into a Basic MVC App
Choosing a SPA Framework: Deconstructing the TodoMVC
Working with the OAuth Framework
Extending the Possible with Web Components
Chapter 15Advanced Client-Server Communications and Streams
Allowing Cross-Domain Requests
Implementing a PUT Request in Ajax
Sending Binary Data Through Ajax and Loading into an Image
Sharing HTTP Cookies Across Domains
Establishing Two-Way Communication Between Client and Server
Unloading and Zipping Files Using Transform Streams
Testing the Performance and Capability of Your WebSockets Application
Chapter 16Data Visualizations and Client/Server Graphics
Creating an SVG Bar Chart with D3
Mapping Data Point Variations with a Radar Chart
Feeding a Scrolling Timeline via WebSocket
Generating Screenshots of Generated Web Page Content (PhantomJS)
Converting Graphics to Text (Ocrad.js)
Cropping (or Otherwise Modifying) Uploaded Images
Chapter 17Data and Persistence
Validating Form Data
Persisting Information Using HTML5
Using sessionStorage for Client-Side Storage
Creating a localStorage Client-Side Data Storage Item
Using Squel.js to Query a MySQL Database
Persisting Larger Chunks of Data on the Client Using IndexedDB
Accessing Data in the Cloud Using Dropbox Datastores
Chapter 18JavaScript Hits the (Mobile) Road
Creating an Installable, Hosted Web App
Packaging Web Apps for the Amazon Appstore
Building a Basic Android App Using Cordova (PhoneGap)
Porting Where Am I? to Android
Creating a Geolocation Firefox OS App
Porting the Geolocation App to a Google Chrome App
Publishing Your Geolocation App in the Kindle Fire OS Environment
Debugging Your Android or Amazon Fire OS App
Getting Information About the Device
Appendix Up and Running in jsBin and jsFiddle

Erscheint lt. Verlag 10.3.2015
Verlagsort Sebastopol
Sprache englisch
Maße 178 x 232 mm
Gewicht 888 g
Einbandart Paperback
Themenwelt Informatik Web / Internet JavaScript
Schlagworte JavaScript • Webdesign
ISBN-10 1-4919-0188-8 / 1491901888
ISBN-13 978-1-4919-0188-5 / 9781491901885
Zustand Neuware
Haben Sie eine Frage zum Produkt?
Mehr entdecken
aus dem Bereich