运行 ❯
获取您
自己的
网站
×
更改方向
保存代码
更改主题,深色/浅色
转到 Spaces
<!DOCTYPE html> <html> <body> <h1>JavaScript Strings</h1> <h2>The startsWith() Method</h2> <p>startsWith() returns true if a string starts with a specified string:</p> <p id="demo"></p> <p>startsWith() is not supported in Internet Explorer.</p> <script> let text = "Hello world, welcome to the universe."; let result = text.startsWith("Hello", 1); document.getElementById("demo").innerHTML = result; </script> </body> </html>