Introduction

JavaScript is a popular web programming language. Oops. I wrote that sentence five years ago. JavaScript is now much more than just a popular web programming language. In addition to web, JavaScript is now a central language for programming Windows 8 Apps. Using JavaScript, you can now not only write powerful applications for the web, but you can also write native Windows applications.

Now more than ever, people are looking to learn JavaScript—and not just developers—people who haven’t programmed before, or who may have created a web page or two along the way, are recognizing the importance of JavaScript. It’s a great time to learn JavaScript, and this book can help.

This book covers not only JavaScript programming for the web but also covers beginning Windows 8 programming with JavaScript. Even though programming or running JavaScript code doesn’t require Microsoft tools, this book is noticeably Microsoft-centric. The one exception to not requiring Microsoft tools surrounds programming of Windows 8 Apps. If you’re looking for a more generalized JavaScript programming book, please see my JavaScript Step by Step book, which, although more advanced, looks at JavaScript programming through a wider lens.

Who Should Read This Book

This book is intended for readers who want to learn JavaScript but who don’t have a formal background in programming. This characterization includes people who have perhaps created a web page, or simply been interested enough to view the source of a web page. It also includes people who are familiar with another programming language, but want to learn JavaScript.

Regardless of your background, if you’re reading this, you’re likely at the point where you want to learn JavaScript with some structure behind it. You’d like to write JavaScript code for practical applications, and also learn why it works.

In this book, you’ll create the code for the examples, and test that code in one or more web browsers. You can write JavaScript in any text editor, but the book will use a free version of Microsoft Visual Studio as the JavaScript editor.

Assumptions

This book assumes that you’re familiar with basic computing tasks such as typing and saving files, as well as working with programs on the computer. The meaning of terms such as “web browser” should be clear to you as meaning programs such as Internet Explorer, Firefox, Chrome, Safari, Opera, and the like. A term like “text editor” shouldn’t scare you away; hopefully you’ve fired up something like Notepad in Microsoft Windows before.

Who Should Not Read This Book

This book is not intended for readers who already have extensive JavaScript programming experience. Additionally, if you’re completely new to computers and aren’t comfortable with the Internet and using computer software, this book might go somewhat fast for you.

Finally, if you’re looking for a book to solve a specific problem with JavaScript or a book that shows JavaScript programs in a recipe-like manner, then this book isn’t for you. Similarly, if you’re not really interested in programming, and just want to learn how to add a counter or some other JavaScript widget to your page, there are plenty of free tutorials on the web that can help. Remember: this book shows not only how things work but also explains why things work as they do. Making something work once is easy, but explaining it and helping you understand why it works will help you for years to come.

Organization of This Book

The book is organized into eight chapters that build upon each other. Early in the book you will see working code. While you can cut and paste, or use examples from the sample companion code, you’ll have the most success if you enter the examples by hand, typing the code yourself. See the section Code Samples later in this Introduction for more information on working with the code samples.

Conventions and Features in This Book

This book presents information using conventions designed to make the information readable and easy to follow.

  • The book includes several exercises that help you learn JavaScript.

  • Each exercise consists of a series of tasks, presented as numbered steps (1, 2, and so on) listing each action you must take to complete the exercise.

  • Boxed elements with labels such as “Note” provide additional information or alternative methods for completing a step successfully.

  • Text that you type (apart from code blocks) appears in bold.

  • A plus sign (+) between two key names means that you must press those keys at the same time. For example, “Press Alt+Tab” means that you hold down the Alt key while you press the Tab key.

  • A vertical bar between two or more menu items (for example, File | Close), means that you should select the first menu or menu item, then the next, and so on.

System Requirements

Writing JavaScript doesn’t technically require any specialized software beyond a web browser and a text editor of some kind. You will need the following hardware and software to complete the practice exercises in this book:

  • While any modern operating system will work, you’ll find it easier if you’re on a later version of Windows, such as Windows 7 or Windows 8. Additionally, you’ll need Windows 8 in order to follow some of the examples in the book that build Windows 8 Apps.

  • Any text editor will suffice, but you’ll find it easier to work through examples if you use Visual Studio 11, any edition (multiple downloads may be required if using Express Edition products)

  • A computer that has a 1.6GHz or faster processor (2GHz recommended).

  • 1 GB (32 Bit) or 2 GB (64 Bit) RAM (Add 512 MB if running in a virtual machine or SQL Server Express Editions, more for advanced SQL Server editions).

  • 3.5GB of available hard disk space.

  • 5400 RPM hard disk drive.

  • DirectX 9 capable video card running at 1024 x 768 or higher-resolution display.

  • DVD-ROM drive (if installing Visual Studio from DVD).

  • Internet connection to download software or chapter examples.

Depending on your Windows configuration, you might require Local Administrator rights to install or configure Visual Studio 11.

Code Samples

There are numerous code samples throughout the book. As previously stated, you’ll learn the most by typing these in manually. However, I realize that process can become mundane (and I’ll even admit that I don’t type in many examples when I read development books).

To help take the pain out of typing in code examples, this book reuses as much code as possible, so if you type it in once, in most cases you’ll be able to reuse at least some of that code in later examples. This is both a blessing and a curse, because if you type it in incorrectly the first time—and don’t get it working—then that problem will continue in later examples.

For simplicity, you’ll concentrate most of your work on a single HTML and single JavaScript file within the book. This means that you won’t need to create new files repeatedly; instead, you will reuse the files you already have by deleting or replacing code to create the new examples.

To help minimize errors you might make when creating the example code by hand, much of the code shown in the book (and all the formal examples) are included with the companion content for this book. These code examples, and indeed all of the code in the book, have been tested in Internet Explorer 10 and Firefox 10, along with a selection of other browsers such as Chrome and Safari in certain areas.

Follow the instructions to download the 9780735666740_files.zip file.

Installing the Code Samples

Follow these steps to install the code samples on your computer so that you can use them with the exercises in this book:

  1. Unzip the 9780735666740_files.zip file that you downloaded from the book’s website (name a specific directory along with directions to create it, if necessary).

  2. If prompted, review the displayed end user license agreement. If you accept the terms, select the accept option, and then click Next.

Note

If the license agreement doesn’t appear, you can access it from the same web page from which you downloaded the 9780735666740_files.zip file.

Using the Code Samples

The code is organized into several subfolders corresponding to each chapter. Code samples are referenced by name in the book. You can load a code file and other files into a project in Visual Studio. or open the file and copy and paste the contents into the files that you’ll build as part of the book.

Acknowledgments

I’ve written a few books now and I’m thinking I should start an advertising program for the acknowledgements section. (Your name here for $25.) Thanks to Russell Jones and Neil Salkind for making this book possible. Since I wrote my last acknowledgements section, Owen Suehring was born and joins his brother Jakob in trying to distract me from the business of writing books. Speaking of distractions, follow me on Twitter: @stevesuehring.

Of course, it wouldn’t be an acknowledgments section if I didn’t thank Rob and Tim from Partners, and Jim Oliva and John Eckendorf. Thanks to Chris Tuescher. Pat Dunn and Kent Laabs: this is what I’ve been doing instead of updating your websites; I hope you enjoy the book more than updates to your sites.

Errata and Book Support

We’ve made every effort to ensure the accuracy of this book and its companion content. Any errors that have been reported since this book was published are listed on our Microsoft Press site at oreilly.com:

If you find an error that is not already listed, you can report it to us through the same page.

If you need additional support, email Microsoft Press Book Support at .

Please note that product support for Microsoft software is not offered through the addresses above.

We Want to Hear from You

At Microsoft Press, your satisfaction is our top priority, and your feedback our most valuable asset. Please tell us what you think of this book at:

The survey is short, and we read every one of your comments and ideas. Thanks in advance for your input!

Stay in Touch

Let’s keep the conversation going! We’re on Twitter: http://twitter.com/MicrosoftPress

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.227.24.60