![](https://img-blog.csdnimg.cn/20201014180756919.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
JS
文章平均质量分 59
JS
旺仔布丁
这个作者很懒,什么都没留下…
展开
-
split、splice、join
splitsplit()主要是用于对一个字符串进行分割成多个字符串数组。str.split(“”);使用默认的情况下,split(‘’)方法对每个字符进行分割。<script type="text/javascript">var str="How are you doing today?"document.write(str.split(" ") + "<br />")document.write(str.split("") + "<br />").原创 2022-04-21 15:07:37 · 238 阅读 · 0 评论 -
for of和for in
<script> var arr = [1, 3, 4] var obj = { a: 2, b: 4, c: 5 } for (let i in arr) { console.log(i); //012 索引 console.log(arr[i]); //134 值 } for (let i of arr) { console.log(...原创 2022-04-20 13:25:20 · 58 阅读 · 0 评论 -
js事件使用
事件使用方式 <div id="app1" onclick="alert('1')">11</div> <div id="app2" onclick="modify()">22</div> 这里要加(),否则不对, 原生要加()。下面写成modify(){}形式也不行 function modify() { alert('2') } <div id="app3">33转载 2022-04-19 13:57:57 · 410 阅读 · 0 评论 -
disabled的使用
disabled是布尔属性对于布尔 attribute (它们只要存在就意味着值为 true)这个属性在html中,只要出现disabled,那么就会禁用在js中可以控制HTML中都禁用 <p>Last name: <input type="text" name="lname" disabled="disabled" /></p> <p>Last name: <input type="text" name="lname" di原创 2022-03-31 15:29:59 · 6326 阅读 · 0 评论 -
foreach reduce filter map
这是毫无意义的:collection.forEach(function () { // do something return false;});因为array#forEach根本不关心其worker函数的返回值.它只是为每个数组元素执行worker函数.您可以使用worker函数来设置外部变量:function truthCheck(collection, pre) { var allAreTruthy = true; collection.forEach(function (原创 2022-03-24 14:39:59 · 1134 阅读 · 0 评论 -
手写js(一)
文章目录一.防抖节流二.深拷贝三.继承一.防抖节流 <button type="button" id="app">按钮</button> <script> // this都指向<button type="button" id="app">防抖</button> // 注意 有时候必须要用箭头函数,才能保证this // 一下子好多都执行这个函数 // +(new Date()) 等于 new D原创 2022-03-25 16:55:41 · 860 阅读 · 0 评论