// 1 array shift
var array = [1, 2, 3];
array.shift();
console.log(array);
array.shift();
console.log(array);
›[2, 3]
›[3]
// 2 array unshift
var array = [1, 2, 3];
array.unshift(4);
console.log(array);
array.unshift(5);```
›[4, 1, 2, 3]
›[5, 4, 1, 2, 3]
// 3 function no parameters
function printFunc() {
console.log("Hello world");
}
printFunc()
printFunc()
// 4 function passing parameters
function Func(a, b) {
console.log(a + b);
}
Func(10, 5)
javascript - functions and array shift unshift
最新推荐文章于 2023-06-30 11:42:48 发布