obkoro1 / web-basics Goto Github PK
View Code? Open in Web Editor NEW大厂前端需要掌握的JS基础能力,大厂场景题、大厂面试真题欢迎提issue和PR来丰富场景题。
License: MIT License
大厂前端需要掌握的JS基础能力,大厂场景题、大厂面试真题欢迎提issue和PR来丰富场景题。
License: MIT License
https://github.com/OBKoro1/web-basics/blob/main/src/scene/numberToCn/numberToCn.js
提供以下测试用例,2个答案均未通过
console.log(trans(1001000)); // 一百万零一千
console.log(trans(11000000)); // 一千一百万
console.log(trans(100000001)); // 一亿零一
// bind返回函数,再在里面执行绑定在context的原函数 Function.prototype.myBind = function(context){ if (context === null || context === undefined) { throw Error(
参数不能为${context}) } else { context = Object(context); } const symbolKey = Symbol('特殊键,用来存储原始this,即原始function'); context[symbolKey] = this; return function(...params){ context[symbolKey](...params); Reflect.deleteProperty(context, symbolKey); }; }
Function.prototype.myBind = function(context){
if (context === null || context === undefined) {
// this参数如果是null/undefined,就指向window,node环境为global
try {
context = window;
} catch(e){
context = global;
}
} else {
context = Object(context);
}
const symbolKey = Symbol('特殊键,用来存储原始this,即原始function');
context[symbolKey] = this;
return function(...params){
context[symbolKey](...params);
Reflect.deleteProperty(context, symbolKey);
};
}
这样可以摆脱对call的依赖,而且保持和myCall、myApply实现原理的一致性
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.