• Complain

Den Odell - Pro JavaScript Development: Coding, Capabilities, and Tooling

Here you can read online Den Odell - Pro JavaScript Development: Coding, Capabilities, and Tooling full text of the book (entire story) in english for free. Download pdf and epub, get meaning, cover and reviews about this ebook. year: 2014, publisher: Apress, genre: Computer. Description of the work, (preface) as well as reviews are available. Best literature library LitArk.com created for fans of good reading and offers a wide selection of genres:

Romance novel Science fiction Adventure Detective Science History Home and family Prose Art Politics Computer Non-fiction Religion Business Children Humor

Choose a favorite category and find really read worthwhile books. Enjoy immersion in the world of imagination, feel the emotions of the characters or learn something new for yourself, make an fascinating discovery.

Den Odell Pro JavaScript Development: Coding, Capabilities, and Tooling
  • Book:
    Pro JavaScript Development: Coding, Capabilities, and Tooling
  • Author:
  • Publisher:
    Apress
  • Genre:
  • Year:
    2014
  • Rating:
    5 / 5
  • Favourites:
    Add to favourites
  • Your mark:
    • 100
    • 1
    • 2
    • 3
    • 4
    • 5

Pro JavaScript Development: Coding, Capabilities, and Tooling: summary, description and annotation

We offer to read an annotation, description, summary or preface (depends on what the author of the book "Pro JavaScript Development: Coding, Capabilities, and Tooling" wrote himself). If you haven't found the necessary information about the book — write in the comments, we will try to find it.

Pro JavaScript Development is a practical guide for front-end web developers who are experienced at building web pages with HTML, CSS, and JavaScript, and now wish to advance their JavaScript skills to a higher level. You will learn how to build large, well-structured, high quality, mobile-optimized web sites and apps, using the latest supported browser APIs, language features, and tools. This book teaches and shows you in practical hands-on terms how you can:

  • Master the performance, reliability, stability, and code manageability of your JavaScript
  • Understand and write efficient object-oriented and prototypal code, including full understanding of the this keyword
  • Boost the performance of your JavaScript code
  • Architect large web applications using common design patterns
  • Write high quality JavaScript code and avoid the pitfalls most likely to cause errors
  • Manage code dependencies with AMD and RequireJS
  • Develop for mobile, build games, and set up a real-time video chat using modern APIs such as Geolocation, Canvas and WebRTC
  • Document your code as the professionals do
  • Write command-line and web server applications in JavaScript with Node.js,
  • Use build tools, such as Grunt and Gulp, to automate repetitive tasks and improve your development workflow

Using real-world examples and applications that youll build yourself, Pro JavaScript Development has unique, practical content that will make you a better JavaScript developer. Become a master of the latest JavaScript coding techniques and tools, and harness its best capabilities today.

What youll learn
  • To build faster and more efficient web apps using the latest techniques
  • How to select the best libraries and frameworks for each project based on design patterns and sound principles
  • To manage JavaScript objects with inheritance through the prototype property and the this keyword
  • To unit test your JavaScript, to measure and improve the quality of your code
  • To create your own web server using Node.js, featuring real-time bidirectional communication with web sockets
Who this book is for

This book is intended for the front-end web developer who is already using JavaScript but wants to know what tools, and techniques they can use to enhance their development. You want to create better apps, better sites, with the best and latest skills.

Table of Contents
  1. Object-Oriented JavaScript
  2. Documenting JavaScript Code
  3. Writing High-Quality JavaScript
  4. Boosting JavaScript Performance
  5. Design Patterns: Creational
  6. Design Patterns: Structural
  7. Design Patterns: Behavioral
  8. Design Patterns: Architectural
  9. Managing Code File Dependencies
  10. Mobile JavaScript Development
  11. Building Games with Canvas API
  12. Using WebRTC for Video Chat
  13. Using Client-Side Templates
  14. The Node.js Application Platform
  15. Build Tools and Automation
  16. Browser Developer Tools

Den Odell: author's other books


Who wrote Pro JavaScript Development: Coding, Capabilities, and Tooling? Find out the surname, the name of the author of the book and a list of all author's works by series.

Pro JavaScript Development: Coding, Capabilities, and Tooling — read online for free the complete book (whole text) full work

Below is the text of the book, divided by pages. System saving the place of the last page read, allows you to conveniently read the book "Pro JavaScript Development: Coding, Capabilities, and Tooling" online for free, without having to search again every time where you left off. Put a bookmark, and you can go to the page where you finished reading at any time.

Light

Font size:

Reset

Interval:

Bookmark:

Make
Den Odell 2014
Den Odell Pro JavaScript Development 10.1007/978-1-4302-6269-5_1
1. Object-Oriented JavaScript
Den Odell 1
(1)
London, United Kingdom
If youve been developing websites for some time, you may have heard other programmers decree that JavaScript is not an object-oriented programming language, and often in the same sentence write off the language as a result. As JavaScript developers, its up to us to educate each other and any naysayers about the JavaScript language, for it is indeed an object-oriented language, and a very powerful one at that.
In reality, when other programmers dismiss JavaScript, they are often belittling it for the fact that it does not adhere to all the same structures and conventions of classical languages, such as C++, Java, PHP, and Objective-C. This is not necessarily a negative, in my opinion, as JavaScript, if written in the right way, actually provides more flexibility by not having such a rigid structure enforced upon it.
In this chapter, I will explain how you can harness the power of JavaScript to write code using object-oriented programming principles adopted by other languages, emphasizing the ways in which this is made more flexible through JavaScript. I will also cover some of the built-in objects contained in the language itself, and some lesser-known facets of these.
Note
A classical programming language is one that defines and creates objects through blueprints or templates known as classes, hence the name.
Objects in JavaScript
An object in JavaScript is a standalone entity consisting of one or more related variables and functions, known as properties and methods, respectively. Objects are used to group together related concepts or functionality, often things that tie back to the real world or to specific software behavior. They make code easier to understand for developers, and so ultimately they make code easier to read and write.
Custom Objects
The simplest way of creating your own object for use in your JavaScript code is to use object literal notation, denoted by curly braces, when defining a variable. Properties and methods can then be attached to the object by encapsulating their names and values within the braces, using the format shown in Listing 1-1. Here we create a new object to represent a house, with two properties and two methods. Once created, we can read and write properties and methods within the object through dot notation, where the object name is separated by the property or method name with a dot ( . ) character.
Listing 1-1.Creating an object using object literal notation
var house = {
rooms: 7,
sharedEntrance: false,
lock: function() {},
unlock: function() {}
};
// Read out the values of the two properties
alert(house.rooms); // 7
alert(house.sharedEntrance); // false
// Execute the 'lock' method of the object
house.lock();
// Update the value for the 'rooms' property
house.rooms = 8;
// Add a completely new property dynamically
house.floors = 2;
// Read out the 'rooms' property again notice it has now changed
alert(house.rooms); // 8
Lets imagine we want to represent another type of property, an apartment. It is similar to a house yet often has fewer rooms and is spread out over a single floor, probably with a shared entrance to the street. Lets represent this in a new variable as an object literal:
var apartment = {
floors: 1,
rooms: 4,
sharedEntrance: true,
lock: function() {},
unlock: function() {}
};
Conceptually, an apartment is like a house but with different properties. If we chose to represent even more types of accommodation in the same way, well soon get into the position where it will be difficult or frustrating to alter the name of a property that we want to share between all these objects, or to add a new property or method to them all. Ideally, we would want to create a template or blueprint that represents the properties and methods of our objects, such that if we wanted to change a property name or add a new method then we could do this with ease. JavaScript allows us to create this kind of object template through constructors, which in other classical languages are commonly known as classes.
Classes
A class is a template or blueprint for similar creating objects that share a set of properties and methods. Programming languages such as Java and Objective-C allow developers to define classes through specific keywords and structures used for just that purpose. In JavaScript, defining a simple function creates some of the same behavior as a class. What makes it different from any other function is not how it is defined, but how objects are created from it.
Note
JavaScript has always had a reserved word called class in its language, which means you cannot create your own variable by that name. It has never actually been used in the language for anything; the name was simply reserved for later use. It appears that this keyword may finally get some usage in a forthcoming revision of the language, known as ECMAScript 6, which is currently being drafted.
Lets create a constructor function which well use as a blueprint for our house and apartment objects. Well add the properties and methods later.
function Accommodation() {};
This looks no different from any other function we could have created in JavaScript. Creating objects using this as a template involves the use of the new keyword followed by the execution of the function.
var house = new Accommodation();
var apartment = new Accommodation();
Any object created using the new keyword is said to be an object instance of the structure represented by the function, essentially its been created as an instance of this template or blueprint. Each object instance created in this way is not connected to any other created from the same template; they are treated as entirely separate variables that merely share an identical blueprint structure. Although the template structure resembles a class in classical programming languages, it is not strictly the same.
Well take a closer look at the constructor function tlater in this chapter.
Detecting An Objects Constructor
Any object literal created from a template in this way has an extra property, called constructor , which points back to the JavaScript constructor function used to create it with. Armed with this knowledge, you can check to see if any object literal in your application matches one of your constructors by comparing the constructor properly directly with the constructor function.
house.constructor === Accommodation; // true
apartment.constructor === Accommodation; // true
You can perform a similar comparison using the instanceof keyword, which compares an object literal with the constructor function used to create it.
house instanceof Accommodation; // true
apartment instanceof Accommodation; // true
In fact, because the constructor property maps directly to the function used to create the instance, you could theoretically create new instances using this property directly, together with the new keyword. This is an uncommon usage, but still interesting to be aware of.
var apartment = new house.constructor();
apartment instanceof Accommodation; // true
Because we defined our class with an empty function, it has none of the properties and methods that we want to use as the template for each object instance. There are two ways of assigning properties and methods to a class, through its prototype and through its scope. Lets look at each now, in turn.
Next page
Light

Font size:

Reset

Interval:

Bookmark:

Make

Similar books «Pro JavaScript Development: Coding, Capabilities, and Tooling»

Look at similar books to Pro JavaScript Development: Coding, Capabilities, and Tooling. We have selected literature similar in name and meaning in the hope of providing readers with more options to find new, interesting, not yet read works.


Reviews about «Pro JavaScript Development: Coding, Capabilities, and Tooling»

Discussion, reviews of the book Pro JavaScript Development: Coding, Capabilities, and Tooling and just readers' own opinions. Leave your comments, write what you think about the work, its meaning or the main characters. Specify what exactly you liked and what you didn't like, and why you think so.