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?
(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.
es-entity ORM framework for Node js based on Ecmascript 6 and Typescript.
Learn what ES6 is, what ECMAScript is, and why it is important to learn for writing modern 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.
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.
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.