Introduction to “reflect-metadata” package and its ECMAScript proposal

Introduction to “reflect-metadata” package and its ECMAScript proposal

In this lesson, we are going to take a look at the reflect-metadata package used by TypeScript to design decorators. Metadata, in a nutshell, is extra information about the actual data. For example, if a variable represents an array, the length of that array is metadata. Similarly, each element in that array is data but the data-type of these elements is metadata. Loosely speaking, metadata is not the actual concern of a program, but it can help us achieve things quicker.

Metadata, in a nutshell, is extra information about the actual data. For example, if a variable represents an array, the length of that array is metadata. Similarly, each element in that array is data but the data-type of these elements is metadata. Loosely speaking, metadata is not the actual concern of a program, but it can help us achieve things quicker.

Let’s take a small example. If you need to design a function that prints information about other functions, what information would you print?

Image for post

(reflect-metadata/func-info.js)

In the above example, the funcInfo function takes a function as an argument and returns a string that contains function name and the number of arguments this function accepts. This information is contained in the function itself, however, we almost never use that in practice. Therefore, func.name and func.length can be considered as metadata.

nodejs ecmascript-6 javascript ecmascript es6

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Orm Framework for Nodejs using Ecmascript 6

es-entity ORM framework for Node js based on Ecmascript 6 and Typescript.

What is ES6, What is ECMAScript & Why You Should Learn it? – JavaScript ES6 for Beginners

Learn what ES6 is, what ECMAScript is, and why it is important to learn for writing modern JavaScript.

What is ECMAScript and How is it Different From JavaScript?

Many times developers use JavaScript and ECMAScript synonymously for each other. Though they are very closely linked to each other, it does not mean they are the same thing.here is a complete story on the history of JavaScript and how it came into existence. To cut the long story short, ECMA in ECMAScript refers to Europen Computer Manufacturers Association to which JavaScript 1.1 was submitted for standardization back in the year 1997.

Introduction to “Reflect” API for Metaprogramming in JavaScript

In this lesson, we are going to learn about the `Reflect` global object available in the ES2015+. It provides various static functions to introspect and modify JavaScript objects. As we learned from the earlier lesson, reflection represents introspection, intercession, and modification of the program. Prior to ES2015 (ES6), we had a few tools available to us to introspect and modify the behavior of the program such as Object.keys or instanceof operator among many.

What are “Internal Slots” and “Internal Methods” in JavaScript?

ECMAScript 2015 specification came up with the idea of internal slots and internal methods that specify the internals properties and methods of the object not exposed to runtime.