Hi there, I'm wangxingkang!
您好,我是王幸康, 前端程序猿一枚.
- 🎉 技术栈 React & Typescript
- 🌱 目前正在学习 Rollup、Babel
- 💬 如果想向我询问任何问题,请在这里询问或者加我微信
xingkang_wang
请备注github
Languages and Tools:
活到老,学到老
License: MIT License
您好,我是王幸康, 前端程序猿一枚.
xingkang_wang
请备注github
Languages and Tools:
bind、call、apply 区别,以及代码实现。
new
的实现原理,手动实现一个new
。
实现一个定时器 setTimeout
;
const setTimeout = (callback: (...args: any[]) => void, ms: number, ...args: any[]) => number
import { useEffect, useRef } from 'react';
export default () => {
const timeoutRef = useRef<NodeJS.Timeout>();
const intervalRef = useRef<NodeJS.Timer>();
useEffect(() => {
timeoutRef.current = setTimeout(
() => {
// your code
},
1000
);
intervalRef.current = setInterval(
() => {
// your code
},
2000
);
return () => {
timeoutRef.current && clearTimeout(timeoutRef.current);
intervalRef.current && clearInterval(intervalRef.current);
}
})
return null;
}
['1', '2', '3'].map(parseInit)
这行代码输出什么,为什么。
给定一个字符串 (s) 和一个字符模式 (p) ,实现一个支持 '?' 和 '*' 的通配符匹配。
'?' 可以匹配任何单个字符。
'*' 可以匹配任意字符串(包括空字符串)。
两个字符串完全匹配才算匹配成功。
说明:
s
可能为空,且只包含从 a-z 的小写字母。p
可能为空,且只包含从 a-z 的小写字母,以及字符 ? 和 *。示例 1:
输入:
s = "aa"
p = "a"
输出: false
解释: "a" 无法匹配 "aa" 整个字符串。
示例 2:
输入:
s = "aa"
p = "*"
输出: true
解释: '*' 可以匹配任意字符串。
示例 3:
输入:
s = "cb"
p = "?a"
输出: false
解释: '?' 可以匹配 'c', 但第二个 'a' 无法匹配 'b'。
示例4
输入:
s = "adceb"
p = "*a*b"
输出: true
解释: 第一个 '*' 可以匹配空字符串, 第二个 '*' 可以匹配字符串 "dce".
示例5
输入:
s = "acdcb"
p = "a*c?b"
输入: false
给定一个字符串s
,最多删除一个字符,判断是否能成为回文字符串。
function validPalindrome(str: string): boolean;
validPalindrome('aba'); // true
validPalindrome('abca'); // true
注意: 字符串只包含a-z的小写字母,字符串的最大长度为50000
实现一个 sleep 函数,比如 sleep(1000) 意味着等待1000毫秒。
给定一个只包含(
、)
的字符串,判断字符串是否有效,有效字符串需满足:
注意: 空字符串可被认为是有效字符串
function isVerify(str: string): boolean;
isVerify('()'); // true
isVerify('()()()'); // true
isVerify('((())())'); // true
isVerify('())'); // false
isVerify('()('); // false
什么是深拷贝,和浅拷贝有什么区别,分别动手实现下浅拷贝和深拷贝;
给你一个字符串 s 和一个字符规律 p,请你来实现一个支持 '.' 和 '*' 的正则表达式匹配。
.
匹配任意单个字符*
匹配零个或多个前面的那一个元素所谓匹配,是要涵盖 整个 字符串 s的,而不是部分字符串。
示例 1:
输入:s = "aa" p = "a"
输出:false
解释:"a" 无法匹配 "aa" 整个字符串。
示例 2:
输入:s = "aa" p = "a*"
输出:true
解释:因为 '*' 代表可以匹配零个或多个前面的那一个元素, 在这里前面的元素就是 'a'。因此,字符串 "aa" 可被视为 'a' 重复了一次。
示例 3:
输入:s = "ab" p = ".*"
输出:true
解释:".*" 表示可匹配零个或多个('*')任意字符('.')。
示例 4:
输入:s = "aab" p = "c*a*b"
输出:true
解释:因为 '*' 表示零个或多个,这里 'c' 为 0 个, 'a' 被重复一次。因此可以匹配字符串 "aab"。
示例 5:
输入:s = "mississippi" p = "mis*is*p*."
输出:false
提示:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.