CHAPTER 25 Summary of JavaScript Idioms in This Book


  • Reviewing the unique aspects of JavaScript objects, variables, and functions
  • Reviewing other JavaScript idioms

There are enough syntactic similarities between JavaScript and C# or Java that many developers don’t think twice about jumping in and writing JavaScript using the same concepts and constructs that they’ve used to build C# or Java programs.

Taking such an approach, however, invariably leads to unwieldy JavaScript code that has neither the type safety of C# and Java nor the elegance of good JavaScript. In order to create truly reliable JavaScript applications, you must understand the quirks that make JavaScript what it is: a flexible, powerful, and elegant programming language.

While this book explicitly is not a JavaScript primer, there are some features of the JavaScript language that are worthy of explicit review. This chapter highlights some of the unique, idiomatic aspects of JavaScript that were used in the preceding chapters.


JavaScript has only five primitive types: String, Number, Boolean, Undefined, and Null. Everything else, including functions, is an object. This section revisits some of the idiomatic aspects of JavaScript objects that we’ve used in the book.

Object Properties May Be Added and Removed

A JavaScript object’s dynamic nature means it may be manipulated in interesting ways. Generally speaking, once an object has been created in C# or ...

Get Reliable JavaScript: How to Code Safely in the World's Most Dangerous Language now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.