Skip to Content
JavaScript: The Definitive Guide, 7th Edition
book

JavaScript: The Definitive Guide, 7th Edition

by David Flanagan
May 2020
Intermediate to advanced
706 pages
21h 15m
English
O'Reilly Media, Inc.
Book available
Content preview from JavaScript: The Definitive Guide, 7th Edition

Chapter 14. Metaprogramming

This chapter covers a number of advanced JavaScript features that are not commonly used in day-to-day programming but that may be valuable to programmers writing reusable libraries and of interest to anyone who wants to tinker with the details about how JavaScript objects behave.

Many of the features described here can loosely be described as “metaprogramming”: if regular programming is writing code to manipulate data, then metaprogramming is writing code to manipulate other code. In a dynamic language like JavaScript, the lines between programming and metaprogramming are blurry—even the simple ability to iterate over the properties of an object with a for/in loop might be considered “meta” by programmers accustomed to more static languages.

The metaprogramming topics covered in this chapter include:

  • §14.1 Controlling the enumerability, deleteability, and configurability of object properties

  • §14.2 Controlling the extensibility of objects, and creating “sealed” and “frozen” objects

  • §14.3 Querying and setting the prototypes of objects

  • §14.4 Fine-tuning the behavior of your types with well-known Symbols

  • §14.5 Creating DSLs (domain-specific languages) with template tag functions

  • §14.6 Probing objects with reflect methods

  • §14.7 Controlling object behavior with Proxy

14.1 Property Attributes

The properties of a JavaScript object have names and values, of course, but each property also has three associated attributes that specify how that ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Modern JavaScript from The Beginning [Second Edition] - Second Edition

Modern JavaScript from The Beginning [Second Edition] - Second Edition

Brad Traversy
JavaScript from Beginner to Professional

JavaScript from Beginner to Professional

Rob Percival, Laurence Svekis, Maaike van Putten, Codestars By Rob Percival

Publisher Resources

ISBN: 9781491952016Errata PageSupplemental Content