Adding Meta Data to a Primitive in JavaScript

share link

by Abdul Rawoof A R dot icon Updated: Mar 2, 2023

technology logo
technology logo

Guide Kit Guide Kit  

In JavaScript, metadata is nothing but data or information about the data. For example, the date created, file size, author, and date modified are basic document file metadata examples. 

The summary and the description of our data are used to classify, label, organize, and understand data, and searching for data much easier is called metadata simple. With these, companies can manage the massive amounts of data created and collected across an enterprise. We have three diverse types of metadata, 

  • Descriptive 
  • Administrative. 
  • Structural. 

The use of adding metadata is, it ensures that data are FAIR: Findable, Accessible, Interoperable, and Re-usable. 

  • Findable: metadata makes it easier to find relevant data for the user. Most searchers use text, so the formats like audio, video, and images are limited unless textual metadata is available. 
  • Accessible: once the user finds the data they need, the metadata indicates how it can be accessed, including authentication and authorization. 
  • Interoperable: enables a dataset to be integrated with other data, and in addition, we also make it easier for data to be interoperable with applications for storing, processing, and analysis. 
  • Re-usable: researchers need to understand how the data are structured to re-use the dataset. 

Here is an example of how to add metadata to a primitive in JavaScript: 

Fig : Preview of the output that you will get on running this code from your IDE.



Follow the steps carefully to get the output easily.

  1. Install JavaScript ES6 code snippet and Code Runner from Extension on your IDE(We use Visual Studio Code).
  2. Copy the snippet using the 'copy' and create one new file filename.js(eg.test.js) then paste the code in that JavaScript file.
  3. Save the file and run the file using run button to generate the output.

I hope you found this useful.

I found this code snippet by searching for 'how to add meta data to a primitive in javascript' in kandi. You can try any such use case!

Environment Tested

I tested this solution in the following versions. Be mindful of changes when working with other versions.

  1. The solution is created and tested in Visual Studio Code 1.74.1.
  2. JavaScript ES6 Code Snippet version v1.8.0.
  3. Code Runner version v0.11.8.

Using this solution, we are able to add meta data to a primitive in javascript with simple steps. This process also facilities an easy way to use, hassle-free method to create a hands-on working version of code which would help us to add meta data to a primitive in javascript.


  1. For any support on kandi solution kits, please use the chat
  2. For further learning resources, visit the Open Weaver Community learning page.