Copy link to clipboard
Copied
I am trying to return the length of a variable in Javascript in Adobe Acrobat DC. I tried Googling and all I could find were posts saying to use Length, Len, length, le but none of them worked. I would get a reference error saying that the function was not defined. Any ideas?
Copy link to clipboard
Copied
The correct property to use is "length", but it only applies for strings and arrays.
If you have another type of variable you'll have to convert it to one of those two types first, and then you'll be able to find out its length.
For example, if you have a Number variable and want to find out how long it is, you can do so like this:
var a = 123;
app.alert("Length of 'a' is: " + a.toString().length);
Copy link to clipboard
Copied
Can you explain the issue? Is this a variable with a text string?
Copy link to clipboard
Copied
I got it to work but thank you for the williness to help.
Copy link to clipboard
Copied
The correct property to use is "length", but it only applies for strings and arrays.
If you have another type of variable you'll have to convert it to one of those two types first, and then you'll be able to find out its length.
For example, if you have a Number variable and want to find out how long it is, you can do so like this:
var a = 123;
app.alert("Length of 'a' is: " + a.toString().length);

