运行 ❯
获取您
自己的
网站
×
更改方向
保存代码
更改主题,暗色/亮色
前往 Spaces
<!DOCTYPE html> <html> <body> <h1>JavaScript Strings</h1> <h2>The slice() Method</h2> <p>Extract a part of a string and return the extracted parts in a new string:</p> <p id="demo"></p> <script> let text = "Apple, Banana, Kiwi"; let part = text.slice(-12,-6) document.getElementById("demo").innerHTML = part; </script> </body> </html>