Hi Fred,
Some of the header pins on the BB-AI64 are connected to two different pins on the MPU. These are then labelled A & B.
If you are looking at the schematic (page 25) you can see the P9.42 is connected to signal AC2_AJ21. If you look further down the same page you can see that signal is then connected to pad AC2 and pad AJ21 on the MPU.
If using function A, then function B pin muxing needs to be set as a GPIO input or vice versa if using function B to prevent the possibility or driving 2 outputs together.
I posted a spreadsheet with the various possible pinmux combintation for the headers here Pinmux spreadsheet
If you are following an example for the BBB it will probably need some work as the two boards are very different. P9.42 on the BBB is GPIO0.7 Depending on how the pin muxing is setup, P9.42 on the AI64 could be either GPIO0.123 or GPIO0.18
I have never used JS, I am a C/Python/Bash scripting person myself.
You can try exporting either GPIO0.123 or GPIO0.18 from a terminal and seeing if you can read the input value.