<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <style> body { font-family: "Microsoft YaHei", serif; } body, dl, dd, p, h1, h2, h3, h4, h5, h6 { margin: 0; } ol, ul, li { margin: 0; padding: 0; list-style: none; } img { border: none } </style> </head> <body> <script> let a = "abc张宇1234567"; let b = a.substring(3,5); //如果写了负数会认为是0,这个可以5,3 console.log(b); let c = a.slice(-5,-2); //这个可以是负数,这个不可以5,3 console.log(c); </script> </body> </html>