When creating a class and its prototype, must the Script Include name match the class name?

Prepare effectively for the ServiceNow CAD certification. Study with detailed questions and explanations. Enhance your skills and knowledge for success in your exam!

Multiple Choice

When creating a class and its prototype, must the Script Include name match the class name?

Explanation:
In ServiceNow Script Includes, the name of the Script Include becomes the constructor you use to create instances. The class you define inside is tied to that Script Include’s name, so you instantiate with new ScriptIncludeName(). For example, if the Script Include is named InventoryHelper, you typically define the class as InventoryHelper = Class.create(); InventoryHelper.prototype = { initialize: function(){}, ... }; Then you create an instance with new InventoryHelper(). If you tried to instantiate with a different name, there wouldn’t be a corresponding constructor exposed, leading to errors. This is why the Script Include name must match the class name used to instantiate.

In ServiceNow Script Includes, the name of the Script Include becomes the constructor you use to create instances. The class you define inside is tied to that Script Include’s name, so you instantiate with new ScriptIncludeName(). For example, if the Script Include is named InventoryHelper, you typically define the class as InventoryHelper = Class.create(); InventoryHelper.prototype = { initialize: function(){}, ... }; Then you create an instance with new InventoryHelper(). If you tried to instantiate with a different name, there wouldn’t be a corresponding constructor exposed, leading to errors. This is why the Script Include name must match the class name used to instantiate.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy