In Scripting, what to put in quotes and what not to put in quotes?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2018 11:00 PM
Hi Developers,
While scripting, when to use the quotes and when not to use the quotes? Does Single quotes & Double quotes have different meaning?
Which is right from following?
Eg: current.state=='1' OR current.state==1
current.u_proposed_as_critical== 'true' OR current.u_proposed_as_critical== true
Thanks in advance,
Snehal
- 3,672 Views

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2018 11:13 PM
Hi Snehal,
Thanks for asking a good question in which the new programmers struggle to understand in starting.
1) If you are defining a variable or a argument or an object in a script snippet earlier and you are using them later in script should not use quotes.
Eg1:
var ab = 1;
if you want to print ab value :-
gs.print(ab); //result => 1
gs.print("ab"); / gs.print('ab') //result => ab
2) Single quote/double quote will make "string".
eg:
var a = 1;
var b = '1';
now a is a integer & b is a string
if you execute this code you will understand:-
var a =1;
var b ='1';
gs.print(typeOf(a));//integer
gs.print(typeOf(b));//string
3) For boolean operators 'true' and true both are valid if you use "==" for comparison.
Eg:-
var a=1;
var b='1';
gs.print(a == b);//true {== it only checks for value}
gs.print(a === b);//false {this is because === symbol checks for value and type both should match}
Thanks,
Saikiran Guduri (NOW)
(Please mark the answer as correct answer/helpful if it helps)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2018 12:00 AM
Hi Saikiran,
Thanks a lot for the reply. This would really be helpful to me.
Can you tell me which one is right from below:
Which is right from following?
Eg: current.state=='1' OR current.state==1 (its the state value of incident)
current.u_proposed_as_critical== 'true' OR current.u_proposed_as_critical== true (this is from incident)
Regards,
Snehal

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2018 12:11 AM
Hi Snehal,
as you are using "==" (double equal to for comparison) all of them will yield the same result.
All the below are valid for "==":
current.state=='1' OR current.state==1 (its the state value of incident)
current.u_proposed_as_critical== 'true' OR current.u_proposed_as_critical== true (this is from incident)
Thanks,
Saikiran Guduri (NOW)
(Please mark the answer as correct answer/helpful if it helps)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2018 12:22 AM
Hi Saikiran,
Thanks a lot for the reply.