@Begins (JavaScript)
Determines whether a string begins with a substring.
Defined in
@Functions (JavaScript)Syntax
@Begins(value:string,subString:string)
: int
Parameter | Description |
---|---|
value |
The string to be checked. |
subString |
The substring to be checked. |
Return value | Description |
---|---|
int |
1 if true, 0 otherwise. |
Usage
This function is case-sensitive.
Examples
This example checks for a substring beginning a string twice.function p(stuff) {
print("<<<" + stuff + ">>>");
}
var s1 = "Now is the time.";
var s2 = "N";
if(@Begins(s1, s2) == @True()) // returns 1
p("String s1 begins with " + s2);
else
p("String s1 does not begin with " + s2);
s2 = "n";
if(@Begins(s1, s2) == @True()) // returns 0
p("String s1 begins with " + s2);
else
p("String s1 does not begin with " + s2);