I have a path which is passed down to me as a javascript variable, which will reference to an image (maybe). ../app/assets/icon.png
. In the case that the path is invalid or doesn't exist, I want to use a different file, located somewhere else. In the end, it should look something like this:
var verifiedPath = existsAndIsValid(path) ? path : '../app/default/icon.png'
Is there a simple one-liner in which I can do this?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.