
JavaScript: A Beginner's Guide, Fifth Edition
Description
Alles über E-Books | Antworten auf Fragen rund um E-Books, Kopierschutz und Dateiformate finden Sie in unserem Info- & Hilfebereich.
More details
Other editions
Additional editions

Content
- Cover
- Title Page
- Copyright Page
- Dedication
- Contents
- ACKNOWLEDGMENTS
- INTRODUCTION
- 1 Introduction to JavaScript
- What You Need to Know
- Basic HTML and CSS Knowledge
- Basic Text Editor and Web Browser Knowledge
- Which Version?
- Client-Side and Server-Side Programming
- Beginning with JavaScript
- Prototype-Based
- Interpreted Language
- Numerous Environments
- Putting It All Together
- Online Resources
- Try This 1-1: Use JavaScript to Write Text
- Chapter 1 Self Test
- 2 Placing JavaScript in an HTML File
- Using the HTML Script Tags
- Identifying the Scripting Language
- Calling External Scripts
- Specifying when the Script Should Load
- Using &noscript&&/noscript& Tags
- Creating Your First Script
- Writing a "Hello World" Script
- Creating an HTML Document for the Script
- Inserting the Script into the HTML Document
- Try This 2-1: Insert a Script into an HTML Document
- Using External JavaScript Files
- Creating a JavaScript File
- Creating the HTML Files
- Viewing the Pages in Your Browser
- Try This 2-2: Call an External Script from an HTML Document
- Using JavaScript Comments
- Inserting Comments on One Line
- Adding Multiple-Line Comments
- Chapter 2 Self Test
- 3 Using Variables
- Understanding Variables
- Why Variables Are Useful
- Variables as Placeholders for Unknown Values
- Variables as Time-Savers
- Variables as Code Clarifiers
- Defining Variables for Your Scripts
- Declaring Variables
- Assigning Values to Variables
- Naming Variables
- Understanding Data Types
- Number
- String
- Boolean
- Null
- Undefined
- Symbol
- Object
- Try This 3-1: Declare Variables
- Using Variables in Scripts
- Making a Call to a Variable
- Adding Variables to Text Strings
- Writing a Page of JavaScript
- Creating the Framework
- Defining the Variables
- Adding the Commands
- Modifying the Page
- Try This 3-2: Create an HTML Page with JavaScript
- Chapter 3 Self Test
- 4 Using Functions
- What a Function Is
- Why Functions Are Useful
- Structuring Functions
- Declaring Functions
- Defining the Code for Functions
- Naming Functions
- Adding Arguments to Functions
- Adding Return Statements to Functions
- Calling Functions in Your Scripts
- Script Tags: Head Section or Body Section
- Calling a Function from Another Function
- Calling Functions with Arguments
- Calling Functions with Return Statements
- Other Ways to Define Functions
- Try This 4-1: Create an HTML Page with Functions
- Scope/Context Basics
- Global Context
- Function Context
- Block Context
- Try This 4-2: Write Your Own Functions
- Chapter 4 Self Test
- 5 JavaScript Operators
- Understanding the Operator Types
- Understanding Arithmetic Operators
- The Addition Operator (+)
- The Subtraction Operator (-)
- The Multiplication Operator (*)
- The Division Operator (/)
- The Modulus Operator (%)
- The Increment Operator (++)
- The Decrement Operator (- -)
- The Unary Plus Operator (+)
- The Unary Negation Operator (-)
- The Exponentiation Operator
- Understanding Assignment Operators
- The Assignment Operator (=)
- The Add-and-Assign Operator (+=)
- The Subtract-and-Assign Operator (-=)
- The Multiply-and-Assign Operator (*=)
- The Divide-and-Assign Operator (/=)
- The Modulus-and-Assign Operator (%=)
- The Exponent-and-Assign Operator (**=)
- Try This 5-1: Adjust a Variable Value
- Understanding Comparison Operators
- The Is-Equal-To Operator (==)
- The Is-Not-Equal-To Operator (!=)
- The Strict Is-Equal-To Operator (===)
- The Strict Is-Not-Equal-To Operator (!==)
- The Is-Greater-Than Operator (&)
- The Is-Less-Than Operator (&)
- The Is-Greater-Than-or-Equal-To Operator (&=)
- The Is-Less-Than-or-Equal-To Operator (&=)
- Understanding Logical Operators
- The AND Operator (&&)
- The OR Operator (||)
- The NOT Operator (!)
- The Bitwise Operators
- Special Operators
- Understanding Order of Operations
- Try This 5-2: True or False?
- Chapter 5 Self Test
- 6 Conditional Statements and Loops
- Defining Conditional Statements
- What Is a Conditional Statement?
- Why Conditional Statements Are Useful
- Using Conditional Statements
- Using if/else Statements
- Using the switch Statement
- Using the Conditional Operator
- User Input from a Prompt
- Try This 6-1: Work with User Input
- Defining Loops
- What Is a Loop?
- Why Loops Are Useful
- Using Loops
- for
- while
- do while
- for in, for each in, and for of
- Using break and continue
- Try This 6-2: Work with for Loops and while Loops
- Chapter 6 Self Test
- 7 JavaScript Arrays
- What Is an Array?
- Why Arrays Are Useful
- Defining and Accessing Arrays
- Naming an Array
- Defining an Array
- Accessing an Array's Elements
- Using the length Property and Loops
- Changing Array Values and Changing the Length
- Try This 7-1: Use Loops with Arrays
- Array Properties and Methods
- Properties
- Methods
- Nesting Arrays
- Defining Nested Arrays
- Loops and Nested Arrays
- Try This 7-2: Nested Arrays Practice
- Chapter 7 Self Test
- 8 Objects
- Defining Objects
- Creating Objects
- Naming
- Single Objects
- Try This 8-1: Create a Computer Object
- Object Structures
- Constructor Functions
- Using Prototypes
- The class Keyword
- Helpful Statements for Objects
- The for-in Loop
- The with Statement
- Try This 8-2: Practice with the Combination Constructor/Prototype Pattern
- Understanding Predefined JavaScript Objects
- The Navigator Object
- The History Object
- Chapter 8 Self Test
- 9 The Document Object
- Defining the Document Object
- Using the Document Object Model
- Using the Properties of the Document Object
- Collections
- The cookie Property
- The dir Property
- The lastModified Property
- The referrer Property
- The title Property
- The URL Property
- The URLUnencoded Property
- Using the Methods of the Document Object
- The get Methods for Elements
- The open() and close() Methods
- The write() and writeln() Methods
- Using DOM Nodes
- DOM Node Properties
- DOM Node Methods
- Try This 9-1: Add a DOM Node to the Document
- Creating Dynamic Scripts
- Styles in JavaScript
- Simple Event Handling
- Coding a Dynamic Script
- Try This 9-2: Try Out Property Changes
- Chapter 9 Self Test
- 10 Event Handlers
- What Is an Event Handler?
- Why Event Handlers Are Useful
- Understanding Event Handler Locations and Uses
- Using an Event Handler in an HTML Element
- Using an Event Handler in the Script Code
- Learning the Events
- The Click Event
- Focus and Blur Events
- The Load and Unload Events
- The Reset and Submit Events
- The Mouse Events
- The Keyboard Events
- Try This 10-1: Focus and Blur
- Other Ways to Register Events
- The addEventListener() Method
- The attachEvent() Method
- The Event Object
- DOM and Internet Explorer: DOM Level 0 Registration
- Using event with Modern Event Registration
- Properties and Methods
- Event Information
- Try This 10-2: Using addEventListener()
- Creating Scripts Using Event Handlers
- Show Hidden Content
- Change Content
- Custom Events
- Chapter 10 Self Test
- 11 Introduction to Node.js
- Introducing Node.js
- Installing Node.js
- Check for a Current Installation
- Install Node.js
- Write a "Hello World" Script
- Using Node Modules
- Using Native Node Modules
- Asynchronous Execution
- Non-Native Modules
- Try This 11-1: Use a Custom Module
- Installing a Database
- Database Options
- Install PostgreSQL
- Create a Database Using pgAdmin
- Try This 11-2: Test Some SQL Queries
- Creating a Web Server
- Chapter 11 Self Test
- 12 Math, Number, and Date Objects
- Using the Math Object
- What Is the Math Object?
- How the Math Object Is Useful
- Properties
- Methods
- Try This 12-1: Display a Random Link on a Page
- Understanding the Number Object
- Properties
- Methods
- Using the Date Object
- Properties and Methods
- Methods That Get Values
- Methods That Set Values
- Other Methods
- How About Some Date Scripts?
- Try This 12-2: Create a JavaScript Clock
- Continuing Project
- Getting to the Needed Data
- Running Some Calculations on the Results
- Chapter 12 Self Test
- 13 Handling Strings
- Introduction to the String Object
- The String Object
- The String Literal
- What's the Difference?
- Using the Properties and Methods of the String Object
- The length Property
- Methods of the String Object
- Try This 13-1: Use indexOf() to Test an Address
- Using Cookies
- Setting a Cookie
- Reading a Cookie
- Try This 13-2: Remember a Name
- Using Regular Expressions
- Creating Regular Expressions
- Testing Strings Against Regular Expressions
- Adding Flags
- Creating Powerful Patterns
- Grouping Expressions
- The replace(), match(), matchAll(), and search() Methods
- More Information
- Continuing Project
- Chapter 13 Self Test
- 14 Browser-Based JavaScript
- Window: The Global Object
- Using the Properties of the Window Object
- The closed Property
- The frames Property
- The innerWidth and innerHeight Properties
- The length Property
- The location Property
- The name Property
- The opener Property
- The parent, self, and top Properties
- The status and defaultStatus Properties
- Try This 14-1: Use the location and innerWidth Properties
- Using the Methods of the Window Object
- The alert(), prompt(), and confirm() Methods
- The print() Method
- The setInterval() and clearInterval() Methods
- The setTimeout() and clearTimeout() Methods
- Try This 14-2: Use the setTimeout() and confirm() Methods
- The Main Window and New Windows
- The Tale of Pop-up Windows
- Opening New Windows
- Closing New Windows
- Moving, Resizing, and Scrolling New Windows
- The resizeBy() and resizeTo() Methods
- The scrollBy() and ScrollTo() Methods
- Working with Images
- Rollovers
- JavaScript and Frames
- Purpose of Frames
- Accessing Frames
- Breaking Out of Frames
- Using iFrames
- Chapter 14 Self Test
- 15 JavaScript Forms and Data
- Accessing Forms
- Using the forms Array
- Using an ID
- Using the Properties and Methods of the Form Object
- Properties
- Methods
- Ensuring the Accessibility of Forms
- Using Proper Element and Label Order
- Using &label&&/label& Tags
- Using &fieldset&&/fieldset& Tags
- Not Assuming Client-Side Scripting
- Validation
- Simple Validation
- Techniques
- Check Boxes and Radio Buttons
- Try This 15-1: Request a Number
- HTML5 and Forms
- New Elements
- New Input Types
- New Attributes
- HTML5 Form Validation
- Try This 15-2: Validate a Phone Number with HTML5 or JavaScript
- AJAX and JSON
- AJAX
- JSON
- Chapter 15 Self Test
- 16 Further Browser-Based JavaScript
- Using jQuery
- Obtaining jQuery
- Getting Started: document.ready()
- Using Selectors
- Altering Classes
- Methods for Effects
- Further Reading
- Try This 16-1: Use jQuery to Create Effects
- Debugging Scripts
- Types of Errors
- Using the Console
- Using a Lint Tool
- Browser Developer Tools
- JavaScript and Accessibility
- Separate Content from Presentation
- Enhancing Content
- Try This 16-2: Make This Code Accessible
- JavaScript Security
- Page Protection
- JavaScript and APIs from HTML
- The &canvas& Element
- Drag and Drop
- Try This 16-3: Drag and Drop
- Node.js App Completion
- Update the Node.js Code
- Update the Front-end Code
- Need Help?
- Chapter 16 Self Test
- A Answers to Self Tests
- Chapter 1: Introduction to JavaScript
- Chapter 2: Placing JavaScript in an HTML File
- Chapter 3: Using Variables
- Chapter 4: Using Functions
- Chapter 5: JavaScript Operators
- Chapter 6: Conditional Statements and Loops
- Chapter 7: JavaScript Arrays
- Chapter 8: Objects
- Chapter 9: The Document Object
- Chapter 10: Event Handlers
- Chapter 11: Introduction to Node.js
- Chapter 12: Math, Number, and Date Objects
- Chapter 13: Handling Strings
- Chapter 14: Browser-Based JavaScript
- Chapter 15: JavaScript Forms and Data
- Chapter 16: Further Browser-Based JavaScript
- Index
System requirements
File format: ePUB
Copy protection: Adobe-DRM (Digital Rights Management)
System requirements:
- Computer (Windows; MacOS X; Linux): Install the free reader Adobe Digital Editions prior to download (see eBook Help).
- Tablet/smartphone (Android; iOS): Install the free app Adobe Digital Editions or the app PocketBook before downloading (see eBook Help).
- E-reader: Bookeen, Kobo, Pocketbook, Sony, Tolino and many more (not Kindle).
The file format ePub works well for novels and non-fiction books – i.e., „flowing” text without complex layout. On an e-reader or smartphone, line and page breaks automatically adjust to fit the small displays.
This eBook uses Adobe-DRM, a „hard” copy protection. If the necessary requirements are not met, unfortunately you will not be able to open the eBook. You will therefore need to prepare your reading hardware before downloading.
Please note: We strongly recommend that you authorise using your personal Adobe ID after installation of any reading software.
For more information, see our ebook Help page.
File format: PDF
Copy-Protection: Adobe-DRM (Digital Rights Management)
System requirements:
- Computer (Windows; MacOS X; Linux): Install the free reader Adobe Digital Editions prior to download (see eBook Help).
- Tablet/smartphone (Android; iOS): Install the free app Adobe Digital Editions or the app PocketBook before downloading (see eBook Help).
- E-reader: Bookeen, Kobo, Pocketbook, Sony, Tolino and many more (only limited: Kindle).
The file format PDF always displays a book page identically on any hardware. This makes PDF suitable for complex layouts such as those used in textbooks and reference books (images, tables, columns, footnotes). Unfortunately, on the small screens of e-readers or smartphones, PDFs are rather annoying, requiring too much scrolling.
This eBook uses Adobe-DRM, a „hard” copy protection. If the necessary requirements are not met, unfortunately you will not be able to open the eBook. You will therefore need to prepare your reading hardware before downloading.
Please note: We strongly recommend that you authorise using your personal Adobe ID after installation of any reading software.
For more information, see our eBook Help page.