Sep 27, 2020

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 Protractor
3. 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();

No comments:

Post a Comment

Thanks a lot for your valuable Comment!

Featured this week

Latest Employment BUZZ: 4 working days in a week?

COVID-19 has hit mostly all sectors including IT  too bad. If we think otherwise, on the other hand,  there have been many new technical inn...