Check how strings begin or end:
let filename = "report.pdf"
console.log(filename.startsWith("report")) // true
console.log(filename.endsWith(".pdf")) // true
console.log(filename.endsWith(".doc")) // false
These are useful for validating formats:
if (url.startsWith("https://")) {
console.log("Secure connection")
}