What is class and function

Shaik22
Tera Expert

Hello,

 

1.What is class and function.

2.What is callback function.

3.How to send response as array of values from script include BR.

2 REPLIES 2

Samaksh Wani
Giga Sage
Giga Sage

Hello @Shaik22 

 

1. Function :- In very simple terms, functions are essentially just small blocks of code that you can encapsulate and name, therefore making that code easily reusable. Sometimes they are referred to as procedures or subroutines.

 

Class :- Classes, on the other hand, are more like blueprints for objects. Objects are specific instances of classes that can have properties (which store information about the object and possible pieces of "state") and methods, which are functions within the class, that can manipulate, validate, present, etc. that objects properties. Classes/objects often emulate real-world objects, such as cars or bank accounts.

 

2.  A callback function is a function passed into another function as an argument, which is then invoked inside the outer function to complete some kind of routine or action.

 

let value = 1;

doSomething(() => {
  value = 2;
});

console.log(value);

 

3. 

var TASK_return_array_SI = Class.create();
TASK_return_array_SI.prototype = Object.extendsObject(AbstractAjaxProcessor, {
    getCallerDetails: function() {
        var caller_sysID = this.getParameter('sysparm_inc');
        var incidentGR = new GlideRecord('sys_user');
        incidentGR.addquery('sys_id', caller_sysID);
        incidentGR.query();
        var array = [];
        if (incidentGR.next()) {
            array.push(incidentGR.name.toString());
            array.push(incidentGR.email.toString());
        }
        return JSON.stringify(array); // convert array to string
    },
    type: 'TASK_return_array_SI'
});

 

Plz Mark my solution as Accept and thumbs up, if you find it helpful.

 

Regards,

Samaksh

 

 

Samaksh Wani
Giga Sage
Giga Sage

Hello @Shaik22 

 

Plz Mark my solution as accept, if you find it helpful.

 

Regards,

Samaksh