JavaScript Patterns

スポンサーリンク

Object-Oriented

Only five primitive types are not objects: number, string, boolean, null, and undefined
Functions are objects, too. They can have properties and methods.
Variable automatically becomes a property of an internal obejct known as an Activation Object
This variable is actually also object-like because it has its own properties.
An object is just a collection of named properties, a list of key-value pairs. (almost identical to an associative array in other languages)
Some of the properties could be functions, in which case we call them methods.
There are two types of objects.
Native : Described in the ECMAScript standard
Host : Defined by the host environment (Ex: browser environment)

No Class in JavaScript

There are no classes in JavaScript.
You don’t need to have a class to create an object.
You create a blank object when you need one and then start adding interesting members to it.
You compose objects by adding primitivese, functions, or other objects to them as their properties.
JavaScript odes have inheritance

Maintainable code

is readable
is consistent
is predictable
looks as if it was written by the same person
is documented

コメント

タイトルとURLをコピーしました