Accessing by value or by reference In JavaScript, a variable may store two types of data: primitive and reference. JavaScript provides six primitive types as undefined, null, boolean, number, string, and symbol , and a reference type object. When you assign a variable a value, the JavaScript engine must determine whether the value is a primitive…