Tag Archives: Average / correct

ES6 determines what the string begins with or ends with

The

startsWith() method determines whether the string startsWith the character of the specified string and returns true or false. The
endsWith() method has the same syntax as the startsWith() method, except that the endsWith() method starts at the end of the string.

let str = "https://C:/Users/2/1.png";
console.log(str.startsWith("https://"))// true;
console.log(str.startsWith("http://"))// false;
console.log(str.endsWith(".jpg"))// false;
console.log(str.endsWith(".png"))// true;