Skip to main content
Inspiring
May 18, 2023
Answered

Using "+" with getField("num.CD.BPAC.01").value;

  • May 18, 2023
  • 2 replies
  • 1716 views

When is it appropriate to use the + sign with getField? I have seen it written these two ways and both seem to work the same:

     var num = getField("num.CD.BPAC.01").value;

and

     var num = +getField("num.CD.BPAC.01").value;

This topic has been closed for replies.
Correct answer Test Screen Name

The result is often the same, but consider what happens if you type 0001. 

getField("num.CD.BPAC.01").value, put back in another field, gives you "0001".

+getField("num.CD.BPAC.01").value gives you "1".

2 replies

Test Screen NameCorrect answer
Legend
May 19, 2023

The result is often the same, but consider what happens if you type 0001. 

getField("num.CD.BPAC.01").value, put back in another field, gives you "0001".

+getField("num.CD.BPAC.01").value gives you "1".

ODuinnAuthor
Inspiring
May 19, 2023

Thank you for this clarification, of which I was unaware, but important to understand.

Nesa Nurani
Community Expert
Community Expert
May 18, 2023

+ will get value as number.

ODuinnAuthor
Inspiring
May 18, 2023

Thank you, that makes sense.