Blogger Information
Blog 10
fans 1
comment 0
visits 6564
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
2019.1.17 js作业_01课
红色熊猫的博客
Original
741 people have browsed it

1:js数组的常用函数(slice()和splice()

var a=[1,25,8,25,825,25,255,12,10];

console.log(a.slice(2,4));//截取下标2开始到下标4结束一段js数组,不包括下标4,不改变原js数组,返回被截取的一段数组。

console.log(a.slice(2));//截取下标2开始到到结尾,不改变原js数组,返回被截取的一段数组。

console.log(a.splice(3));//截取下标3开始后面所有元素,改变原数组,返回被截取的数组

console.log(a.splice(2,5));//截取下标2开始,5个元素,改变原数组,返回被截取的数组

console.log(a.splice(2,2,'sss'));//截取下标2开始2个元素并在数组截取的位置插入字符串sss,返回被截取的数组,改变元素组


2:js引入到html文档中的三种方式,举例说明


①外部引入

<script src="js.js"></script>

②行内写入

<div onclick="check(name)"></div>

③写在HTML标签内

<script>

console.log(454545);

</script>


Correction status:qualified

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post