How to access/get the variable from one javascript file to another javascript file. like first.js contains a function first.js like below.
this.first = function(){
var x = ['new','old']
}
now, I want to access the 'x' in another file say second.js I have tried
var first = require('../first.js'); //path to the first.js file
console.log(first.x)
but getting the undefined value. i want to get/access the 'x' from first.js I am using this for protractor E2E testing using page objects.