<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>array-api</title> </head> <body> </body> <script> var array = ["one", "two", "four"]; console.log(JSON.stringify(array));//["one","two","four"] //在指定位置添加元素,第一個參數指定位置,第二個參數指定要刪除的元素,如果為0,則追加 array.splice(2, 0, "three"); console.log(JSON.stringify(array));//["one","two","three","four"] </script> </html>