Learn Protractor & Jasmine Framework for End to End Testing | Chapter 6 | Functions & Objects in JavaScript
1. Creating methods & functions inside a function in JavaScript
2. Use of it in Protractor3. Create a constructor function and invoke function via object.
4. Export object globally and use it in other files in project.
Demo Website: http://juliemr.github.io/protractor-demo/
File 1: Functions.js
function account()
{
this.ssn=123123123;
this.name="Ishan";
this.accountNumber=444444555;
//method inside function
this.getAccountNumber = function(){
console.log(this.accountNumber);
}
}
// var obj = new account();
// obj.getAccountNumber();
// console.log(obj.ssn);
// console.log(obj.name);
module.exports = new account();
File 2: Functions2.js (To invoke objects and methods from above file)
var obj = require("./Functions");
console.log(obj.ssn);
console.log(obj.name);
obj.getAccountNumber();
Comments
Post a Comment
Thanks a lot for your valuable Comment!