随笔分类 - js
摘要:1.添加函数修改img的属性; /** * * @param {*} idName 传入的id,获取改img的dom,添加相应的数学 */ export const proxyImg = (idName) => { const img = document.getElementById(idName
阅读全文
摘要:数组的32中方法=>{ 1.push(): 在数组末尾添加一个或多个元素,并返回修改后的数组。 let fruits = ['apple', 'banana', 'orange']; fruits.push('mango'); console.log(fruits); // 输出: ['apple'
阅读全文
摘要:字符串的17种方法。。。。。。 1.length:返回字符串的长度。 const str = "Hello, World!"; console.log(str.length); // 输出 13 2.charAt(index):返回指定索引位置的字符。 const str = "Hello, Wor
阅读全文
摘要:const arr1 = [{ id: 1, name: '老二' }]; const arr2 = [{ id: 1, name: '网' }, { id: 2, name: '二位' },{ id: 3, name: '二位' }]; // 第一种 let arr1Ids = arr1.map(
阅读全文