background preloader

The Basics of Object-Oriented JavaScript

The Basics of Object-Oriented JavaScript
Over recent years, JavaScript has increasingly gained popularity, partly due to libraries that are developed to make JavaScript apps/effects easier to create for those who may not have fully grasped the core language yet. While in the past it was a common argument that JavaScript was a basic language and was very 'slap dash' with no real foundation; this is no longer the case, especially with the introduction of high scale web applications and 'adaptations' such as JSON (JavaScript Object Notation). JavaScript can have all that an Object-Orientated language has to offer, albeit with some extra effort outside of the scope of this article. Congratulations, you just created an object. For each of the objects we have created a property 'iAm' which contains a string value that is used in our objects method 'whatAmI' which alerts a message. Properties are variables created inside an object and methods are functions created inside an object. First we will create an Object literal;

Pseudocode Standard Pseudocode is a kind of structured english for describing algorithms. It allows the designer to focus on the logic of the algorithm without being distracted by details of language syntax. At the same time, the pseudocode needs to be complete. It describe the entire logic of the algorithm so that implementation becomes a rote mechanical task of translating line by line into source code. In general the vocabulary used in the pseudocode should be the vocabulary of the problem domain, not of the implementation domain. The pseudocode is a narrative for someone who knows the requirements (problem domain) and is trying to learn how the solution is organized. Extract the next word from the line (good) set word to get next token (poor) Append the file extension to the name (good) name = name + extension (poor) FOR all the characters in the name (good) FOR character = first to last (ok) Note that the logic must be decomposed to the level of a single loop or decision. Example (non-computer)

my favorite discussion of static vs instanciable objects in javascript. i've had to explain this concept an uncountable number of times and have never been able to do it so simply. by snarfel Nov 18

Related: