Skip to main content

2010 | Buch

JavaScript for Absolute Beginners

insite
SUCHEN

Über dieses Buch

If you are new to both JavaScript and programming, this hands-on book is for you. Rather than staring blankly at gobbledygook, you'll explore JavaScript by entering and running hundreds of code samples in Firebug, a free JavaScript debugger. Then in the last two chapters, you'll leave the safety of Firebug and hand-code an uber cool JavaScript application in your preferred text editor.

Written in a friendly, engaging narrative style, this innovative JavaScript tutorial covers the following essentials:

Core JavaScript syntax, such as value types, operators, expressions, and statements provided by ECMAScript. Features for manipulating XHTML, CSS, and events provided by DOM. Object-oriented JavaScript, including prototypal and classical inheritance, deep copy, and mixins. Closure, lazy loading, advance conditional loading, chaining, currying, memoization, modules, callbacks, recursion, and other powerful function techniques. Encoding data with JSON or XML. Remote scripting with JSON-P or XMLHttpRequest Drag-and-drop, animated scrollers, skin swappers, and other cool behaviors. Optimizations to ensure your scripts run snappy. Formatting and naming conventions to prevent you from looking like a greenhorn. New ECMAScript 5, DOM 3, and HTML 5 features such as Object.create(), Function.prototype.bind(), strict mode, querySelector(), querySelectorAll(), and getElementsByClassName().

As you can see, due to its fresh approach, this book is by no means watered down. Therefore, over the course of your journey, you will go from JavaScript beginner to wizard, acquiring the skills recruiters desire.

Inhaltsverzeichnis

Frontmatter
Chapter 1. Representing Data with Values
Abstract
When you walk into my childhood home in Pittsburgh, it’s evident a fellow with a lively mind lives there. Photos from trips to some thirty-one countries on six continents line the walls. Intermingling those are Aborigine and Aleut art, prints by Klimt and Degas, tapestries from Egypt and Peru, and Greek sculptures. Notable literary works fill the library.
Terry McNavage
Chapter 2. Type Conversion
Abstract
Iron Man, Superman, Batman, Spider-Man, X-Men, and countless other superheroes have many traits in common. Most have a distinctive costume, unwavering morals, underlying motif, secret identity, supervillains to fight, and, of course, extraordinary powers. Those powers may or may not be innate, though. For example, Clark Kent doesn’t need his Superman costume to fly, but Tony Stark would drop like a stone without his Iron Man armor.
Terry McNavage
Chapter 3. Operators
Abstract
Having data is no use if you can’t do anything with it, so step forward operators. Operators do just what their name suggests; they operate on things. In the case of JavaScript, those things are the values stored in variables and any other value used in your script. For example, we’d use a division operator to divide one value by another value to return a result. There are some very straightforward operators in JavaScript and some not-so-straightforward ones; we’ll cover all the useful ones and mention the others in passing, even though you will never use them.
Terry McNavage
Chapter 4. Controlling Flow
Abstract
Running a forest trail in May, I startled a doe and her newborn fawn. The doe made a raspy snort to warn the fawn of danger. Not knowing what to do, the fawn wobbled over to me and plopped down between my legs. Trembling with fear, it looked up at me and bleated faintly, imploring me to keep it safe. The doe stood 20 yards off, quivering with agitation. Obviously, it had wanted the fawn to run away from the predator, not to it.
Terry McNavage
Chapter 5. Member Inheritance
Abstract
In this chapter, I’ll cover a feature of JavaScript called inheritance, which is a very useful and powerful tool to acquire. It allows us to write much more ordered and efficient code, because it is a great way to organize your code into useful little lumps. I will cover the following four ways to approach inheritance, each of which has its own place in your programs:
  • Classical
  • Prototypal
  • Deep copy
  • Mixin
Terry McNavage
Chapter 6. Functions and Arrays
Abstract
In the previous chapter, you learned about inheritance and saw how to pass members onto child objects using classical, prototypal, deep copy, and mixin inheritance. As I noted at the end of that chapter, it’s actually functions that are more often passed on to child objects. This is because common processes, as provided by a function, are frequently more useful than common data, as provided by members. In this chapter, I’ll cover why you would want to use functions and how to take advantage of function inheritance. There are a lot of cool tricks to learn in this area and we’ll take advantage of a lot of them in later chapters, as you’ll see from the copious forward references. In other words, this is quite an important chapter.
Terry McNavage
Chapter 7. Traversing and Modifying the DOM Tree
Abstract
One of my favorite books as a child was Where the Wild Things Are by Maurice Sendak. If you are not familiar with the story, it goes like this: one night, a little boy named Max, dressed in a wolf costume, misbehaves and is sent to bed without supper. There, a sea, a wild forest, and mysterious creatures spring from his imagination. Max sails to the land of the wild things, who crown him king. But even though the creatures do his bidding, Max grows hungry for love. So, he sails home to find his supper waiting for him, still hot.
Terry McNavage
Chapter 8. Scripting CSS
Abstract
Booming by a hilly golf course in a new pair of lime green Nike Lunar Elites, I observed some deer running through the deep snow that a blizzard referred to as “Snowmageddon“ had dumped on Pittsburgh. Though I love to run in fresh powder, 3 feet could be too much. But the deer did just fine. Besides, in those lime green shoes, I felt invincible. So, off the road and into the snow I went.
Terry McNavage
Chapter 9. Listening for Events
Abstract
Twenty-five hundred years ago in 490 BC, a Greek herald named Pheidippides ran several dispatches totaling 240 km (150 miles) during the final two days of the Battle of Marathon. The distance of his final run from Marathon to Athens to deliver news of the Greek victory over the Persians with the word Nɛvikήkμɛv (we have won) is the basis for the marathon race being 42 km (26.2 miles). Insofar as Pheidippides ran those dispatches over mountainous terrain in hot weather and would have been 40 (born in 530 BC), it is not surprising that he collapsed and died moments later.
Terry McNavage
Chapter 10. Scripting BOM
Abstract
A while ago, I worked a scene in the Russell Crowe and Liam Neeson film The Next Three Days. Probably the thing that surprised me most was how dynamic things were on set. Paul Haggis, who won two Oscars for Crash, kept reworking the content of the scene, especially the timing; he must have had Jason Beghe (Detective Quinn) run out of every single door in the precinct and say, “We found his son!” each time. Oftentimes Haggis would tell us what to do just moments before filming another take. Needless to say, having a good short-term memory was vital.
Terry McNavage
Backmatter
Metadaten
Titel
JavaScript for Absolute Beginners
verfasst von
Terry McNavage
Copyright-Jahr
2010
Verlag
Apress
Electronic ISBN
978-1-4302-7218-2
Print ISBN
978-1-4302-7219-9
DOI
https://doi.org/10.1007/978-1-4302-7218-2