JavaScript shift() Method 用法
2007-09-22 10:41
330 查看
使用
The shift() method is used to remove and return the first element of an array.语法
arrayObject.shift() |
Tips and Notes
Note: This method changes the length of the array.Tip: To remove and return the last element of an array, use the pop() method.
Example
In this example we will create an array, and then remove the first element of the array. Note that this will also change the length of the array:<script type="text/javascript"> var arr = new Array(3) arr[0] = "Jani" arr[1] = "Hege" arr[2] = "Stale" document.write(arr + "<br />") document.write(arr.shift() + "<br />") document.write(arr) </script> |
Jani,Hege,Stale Jani Hege,Stale |
Try-It-Yourself Demos
shift()How to use shift() to remove and return the first element of an array.
相关文章推荐
- javaScript call 函数的用法说明
- ASP.NET MVC Bundles 用法和说明(打包javascript和css)
- Javascript中的转义用法实例代码
- Javascript模块化编程:require.js的用法
- javascript编程开发中取色器及封装$函数用法示例
- Bash Shell中Shift用法分享
- Bash Shell中Shift用法分享
- JavaScript中promise的基本用法
- JavaScript中的shift()和pop()函数
- javascript常见用法总结
- JavaScript中的公有、私有、特权和静态成员用法分析
- 关于JavaScript中apply与call的用法意义及区别(转)
- javaScript秘密花园,主要关心 JavaScript 一些古怪用法的文档。
- Javascript模块化编程(三):require.js的用法
- JavaScript中的splice方法用法详解
- JavaScript中this的用法
- javascript中clipboardData对象用法详解
- perl中shift与unshift的用法解析
- javascript里的document.all用法
- JavaScript 数组some()和filter()的用法及区别