The CreatorCon Call for Content is officially open! Get started here.

What is Object()?

pradipb
Kilo Explorer

Hi,

Very basic question.

What is Object() and what is the use of it?

Thanks

1 ACCEPTED SOLUTION

Hi Pradip,



It's not specific to ServiceNow. It is a JavaScript data type. It's very much like



var a = new Array();


var a = [];



An object is just an empty space for you to do with what you wish. There are no properties or methods when you create a new object in this way. In a sense, you are right. It's the basis of all other objects.



I invite you to take a look at some of the free online learning material to better understand Javascript and data types. One of my favorites is: JavaScript | Codecademy


View solution in original post

4 REPLIES 4

Chuck Tomasi
Tera Patron

Hi Pradip,



Can you elaborate on your question? Where are you seeing it?



I'm going to make a guess and say you were looking through a script and came across a statement like this:



var o = new Object();



That's a Javascript construct. JavaScript Objects (W3schools.com) It is a "space" used to contain properties, methods, etc. The modern way to write this is:



var o = {};



A great many things in ServiceNow are objects. Most notably the tables and fields (aka GlideRecord object.)



Let me know if I did not answer your question.


Thanks Chuck for responding..


Seems like this is the basic class which might be inherited by other classes used in service now.  


Is there any link / document which gives me details like properties and methods of this Object.  



Pradip


Hi Pradip,



It's not specific to ServiceNow. It is a JavaScript data type. It's very much like



var a = new Array();


var a = [];



An object is just an empty space for you to do with what you wish. There are no properties or methods when you create a new object in this way. In a sense, you are right. It's the basis of all other objects.



I invite you to take a look at some of the free online learning material to better understand Javascript and data types. One of my favorites is: JavaScript | Codecademy


Hi Chuck,

 

Quick question, So how do I use Object.assign()? I am trying to use this but seems not to be working. Throwing "

Cannot find function assign in object function Object()