SeanGXY
SeanGXY
全部文章
分类
题解(16)
归档
标签
去牛客网
登录
/
注册
SeanGXY的博客
全部文章
(共18篇)
题解 | #计数#
function count(arr, item) { let num = 0; for(let k of arr){ num += item==k } return num }
2022-05-20
0
147
题解 | #将字符串转换为驼峰格式#
function cssStyle2DomStyle(sName) { let arr = sName.split("-"); let result = ""; for(let i=0;i<arr.length;i++){ ...
2022-05-20
1
157
题解 | #颜色字符串转换#
// 供君参考 function rgb2hex(sRGB) { if(/(rgb)+\(([0-9]{1,3},?\s*){3}\)/.test(sRGB)){ // 获取数值 let arr = sRGB.match(/[0-9]+/g); ...
2022-05-19
1
173
题解 | #时间格式化输出#
function add(str,data){ if(str.length == 2 && data<10){ return "0"+data; } return data; } function formatDate...
2022-05-19
1
230
题解 | #共同父亲dom节点查找#
function commonParentNode(oNode1, oNode2) { let arr1 = [oNode1]; let arr2 = [oNode2]; let DOM1 = oNode1.parentNode; le...
HTML/CSS/JavaScript
2022-05-08
3
256
题解 | #深拷贝函数实现#
const _completeDeepClone = (target, map = new Map()) => { // map 用来记录是否已经被拷贝过 // 补全代码 if(typeof target == "object" && target !==...
HTML/CSS/JavaScript
2022-05-08
3
479
题解 | #浅拷贝#
const _shallowClone = target => { if(typeof target == "object" && target !== null){ // Array,null 的 type 类型也是 obje...
HTML/CSS/JavaScript
2022-05-08
0
262
题解 | #实现new操作符#
// 目的是使用 new() 方法创建一个 className 类的实例化对象,代替 new className(参数) 的方法 const _new = function(className,...args) { //if(typeof className !== "function") ...
HTML/CSS/JavaScript
2022-05-08
4
226
题解 | #_call函数#
Function.prototype._call = function(target,...args){ target = (typeof target == "object" ? target : window); // 保证要指向的是对象类型 target["temporary"] = ...
HTML/CSS/JavaScript
2022-05-07
0
225
题解 | #合法的URL#
// 补全代码 // 开始符 ^ // 协议部分http(s):// 表示为((https|http|ftp|rtsp|mms)?:\/\/) // 域名部分 表示为(([A-Za-z0-9]+-[A-Za-z0-9]+|[A-Za-z0-9]+)\.)+ // 顶级域名com cn等...
HTML/CSS/JavaScript
2022-05-07
21
888
首页
上一页
1
2
下一页
末页