Based upon Datatype, JavaScript passes a value of a variable using two ways: Using Pass by Value Using Pass by Reference Pass by Value When you pass primitive data types (such as numbers, strings, or booleans) to a function, a copy of the actual value is passed. Changes made to that variable inside…