The v8.cachedDataVersionTag() method is an inbuilt application programming interface of the v8 module which is used to get the version tag derived from the v8 version.
Syntax:
v8.cachedDataVersionTag();
Parameters: This method does not have any parameters.
Return Value: This method returns the version tag from the v8 version, command-line flags, and detected CPU features.
Example 1: The below example illustrates the use of the v8.cachedDataVersionTag() method in Node.js.
index.js
// Accessing v8 module
const v8 = require('v8');
// Calling v8.cachedDataVersionTag()
tag = v8.cachedDataVersionTag();
console.log("cache data version tag is " + tag);
Run the index.js file using the following command:
node index.js
Output:
cache data version tag is 4151506697
Example 2: The below example illustrates the use of the v8.cachedDataVersionTag() method in Node.js.
index.js
// Accessing v8 module
const v8 = require('v8');
// User defined function
function getTagVersion() {
// Initializing with zero
let tagVersion = 0;
// Calling v8.cachedDataVersionTag()
tagVersion = v8.cachedDataVersionTag();
return tagVersion;
}
// Function call
let result = getTagVersion();
// Printing Tag version
console.log("The Cache Data Version is:", result);
Run the index.js file using the following command:
node index.js
Output:
The Cache Data Version is: 1165837633
Reference: https://nodejs.org/api/v8.html#v8_v8_cacheddataversiontag