Or a 3rd is s.list(/^filename$/) which would be more efficient than s.list.
However I'd say s.read(...)!==undefined) is the best. Espruino doesn't actually load the file into memory - it just references it as a string - so it's actually very efficient to just check if it is undefined or not as the file data will never actually even be read.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Or a 3rd is
s.list(/^filename$/)
which would be more efficient thans.list
.However I'd say
s.read(...)!==undefined)
is the best. Espruino doesn't actually load the file into memory - it just references it as a string - so it's actually very efficient to just check if it is undefined or not as the file data will never actually even be read.