7From Signs to Patterns
This chapter gathers several notions about the signs and words used in JavaScript, how they interact with the syntax (the traps of polymorphism), how to use programming constraints to style a more readable and robust code and a few hints about meta-programming.
In any language, punctuation plays a role in the interpretation. It is reported in 1327 that Queen Isabella signed the following order about her husband, Edward II:
Edwardum occidere nolite |
// "do not execute Edward" |
timere bonum est. |
// "to fear is a good thing" |
and it is reported that a comma was added (by who?), after ‘timere’:
Edwardum occidere nolite |
// in a single line, read: |
timere, bonum est. |
//"do not fear to execute Edward, it’s good" |
In any language there are reserved words, sacred or forbidden, and you must replace them: e.g. American “my gosh”, instead of a forbidden word.
In any language there are pronouns, a grammatical form referring to another form, and whenever referencing, ambiguities may occur:
“because of the rain, Paul arrived late at the dentist. He was unhappy”
Who was unhappy? The dentist or Paul?
Ambiguity does not exist in computers, but “errare humanum est”. A human mistake can lead to misinterpretation. Keywords, punctuation and a misused pronoun are often error prone in JavaScript. This chapter is meant to guard you against such mistakes, and also meant to teach some programming best practices: design patterns.
7.1. Reserved words
The table below contains ...
Get JavaScript and Open Data now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.