Copy link to clipboard
Copied
I've been reading that using 'this' instead of 'var', when declaring variables is a better method. Is there a substantive difference?
Copy link to clipboard
Copied
Declaring a variable using the let keyword allows for a variable to have block level scope, which is generally a good thing. The main problem with using it in PDF is related to backwards compatibility with older verisons of Acrobat/Reader, and other PDF viewers that jave some support for JavaScript, but don't support let..
Copy link to clipboard
Copied
The keyword this refers to the current object. The current object is often the document that includes the script, but it also could not be. The keyword var is used to declare a variable. They are not close to being equivalent.
Copy link to clipboard
Copied
I'm not sure what you've been reading but the two are completely different things. To get an idea of how Acrobat JavaScript actually works, you might want to read this article http://khkonsulting.com/2017/01/learning-to-program-javascript-for-adobe-acrobat/
Copy link to clipboard
Copied
Crimany, I'm very sorry, it was 'let', not 'this'. I got mixed up there... Yes, that question made no sense... I wish I could change that title...
Copy link to clipboard
Copied
Declaring a variable using the let keyword allows for a variable to have block level scope, which is generally a good thing. The main problem with using it in PDF is related to backwards compatibility with older verisons of Acrobat/Reader, and other PDF viewers that jave some support for JavaScript, but don't support let..
Copy link to clipboard
Copied
Thank you. It's hard to find decent material on JS for Acrobat...
Copy link to clipboard
Copied
Now that question makes sense. The JS interpreter in Acrobat isn't at the same level as the browsers. There are a lot of key words and common object methods that are not supported.
Stick with "var"
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more