1var str = "Hello world, welcome to the universe.";
2var n = str.startsWith("Hello");
1const str = "Saturday night plans";
2const res = str.startsWith("Sat");
3console.log(res); //> true
1[[ $a == z* ]] # True if $a starts with a "z" (wildcard matching).
2[[ $a == "z*" ]] # True if $a is equal to z* (literal matching).
3
4if [[ "$HOST" =~ ^user.* ]]; then
5 echo "yes"
6fi
7
8if [[ "$HOST" =~ ^user.*|^host1 ]]; then
9 echo "yes"
10fi
11
1const str1 = 'Saturday night plans';
2
3console.log(str1.startsWith('Sat'));
4// expected output: true
5
6console.log(str1.startsWith('Sat', 3));
7// expected output: false
8
1//checks if a string starts with a word
2function startsWith(str, word) {
3 return str.lastIndexOf(word, 0) === 0;
4}
5startsWith("Welcome to earth.","Welcome"); //true
1const s = 'I am going to become a FULL STACK JS Dev with Coderslang';
2
3console.log(s.startsWith('I am')); // true
4console.log(s.startsWith('You are')); // false