避免在firebase.auth().createUserWithEmailAndPassword(电子邮件,密码)上抛出"auth/weak-password"错误代码有哪些要求.
我想向用户显示要求,这样他们就不必在创建帐户的过程中多次抛出错误.
我查看了firebase文档:https://firebase.google.com/docs/reference/js/firebase.auth.Auth
和堆栈溢出但没有找到此信息.谢谢!
toISOString 方法返回错误的日期。
// Input
var a = new Date("June 08, 2018");
a.toISOString().slice(0, 10);
// Output
"2018-06-07"
// Expected output
"2018-06-08"
Run Code Online (Sandbox Code Playgroud) 我试图删除不是abc并且不以abcxx或abcyy开头的句子中的每个'abc' .
所以:
狗abc cat abcxx abcdfxx abcee abcyyli abcb
成为:
dog abc cat abcxx abc dfxx abc ee abcyyli abc b
它的意思是:
狗abc cat abcxx dfxx ee abcyyli b
我在尝试这样的事情:
var text = "dog abc cat abcxx abcdfxx abcee abcyyli abcb";
console.log(
text.replace(/(^((?:abc(?!xx)(?!yy)).*)$)/g, '')
);Run Code Online (Sandbox Code Playgroud)
如果我在每个单词上运行它,它知道检测有问题的单词,并删除所有单词(而不是仅删除'abc').
为什么会这样?
let str = 'sSAo'
console.log(str[0], str[3]) // all good
for (let i in str) {
// why str[i+1] is undefined ???
console.log(i, str[i], str[i+1])
}Run Code Online (Sandbox Code Playgroud)
我用"Javascript Ninja的秘密"中的脚本测试了性能:
function isPrime(number) {
if (number < 2) {
return false;
}
for (let i = 2; i < number; i++) {
if (number % i === 0) {
return false;
}
}
return true;
}
console.time("isPrime");
isPrime(1299827);
console.timeEnd("isPrime");
console.time("isPrime");
isPrime.apply(1299827);
console.timeEnd("isPrime");Run Code Online (Sandbox Code Playgroud)
结果是:
isPrime: 8.276ms
isPrime: 0.779ms
Run Code Online (Sandbox Code Playgroud)
似乎"申请"更快?
我已经编写了一个函数来将诸如'aaazeeeee'之类的字符串转换为'aaa z eeeee'的新字符串
这是我尝试过的代码
const groupCharacters = signature => {
let newSignature = "", arr = [];
let result = [...signature].reduce((accumulator, element, index) => {
// check if last element in accumulator matches current element
if (accumulator[accumulator.length -1] !== element) {
// push accumulator into array
arr.push(accumulator);
// set newSignature as new element
newSignature = element;
} else {
// else add element to newSignature
newSignature = accumulator += element;
}
// if is last item, push to array
if …Run Code Online (Sandbox Code Playgroud)I wrote a little vanilla JavaScript program, but I want to know if there is a possibility to write this simpler? With ES6+? But only with vanila JavaScript, no jQuery or other libraries / frameworks. Thanks in advance for the suggested solutions.
const red = document.getElementById('circleOne');
const green = document.getElementById('circleTwo');
const blue = document.getElementById('circleThree');
red.addEventListener("mouseover", () => {
red.style.backgroundColor = "red";
});
red.addEventListener("mouseout", () => {
red.style.backgroundColor = "white";
});
green.addEventListener("mouseover", () => {
green.style.backgroundColor = "green";
red.style.backgroundColor = "green"; …Run Code Online (Sandbox Code Playgroud)当我使用过滤器时,数字0不包含在新数组中:
function arrayDiff(a, b) {
return a.filter(value => {
if(!b.includes(value)){
return value;
};
});
}
array_diff([1, 2, 0, 4, 2, 6, 4, 1, 4, 0] ,[2,5]);
Run Code Online (Sandbox Code Playgroud)
返回值是:[1, 4, 6, 4, 1, 4]。看看如何缺少0。
我还尝试仅返回数字0,但返回了空数组。
如何解决将.filter0成功包含在结果中的问题?
我最近一直在阅读 JavaScripttop功能,并注意到我可以运行window.top或top.window. 从我所见,功能上没有区别,因此可以同时运行两者似乎很奇怪。
// They appear to be the same here at least:
console.log(window.top === top.window);Run Code Online (Sandbox Code Playgroud)
我的问题是,有谁知道为什么这个功能存在两次,两者之间有什么区别吗?我想知道浏览器支持方面的差异,或者与以一种或另一种方式运行它相关的古怪错误。
经过几年的 Node.js 编程,我已经习惯了 JS,我想知道如何避免C# 中的while循环,通过使用更“类似地图”的方法(如 C# 中的 AddRange)来添加数组中的项目可枚举)。
例如,如果我想要一个 JavaScript 中包含 10 个元素的数组,每个元素都有一个每次递增的属性,我会这样做:
const cells = Array.from({ length:10 }, (_, i) => { 'number': i });
// gives cells = [{number: 0}, {number: 1}, ... until 9]
Run Code Online (Sandbox Code Playgroud)
如何在没有whileorfor循环的 C# 中做到这一点?
int itemWantedCount = 10;
int i = 0;
while(cells.Count < itemWantedCount)
{
cells.Add(new MyObject(i++));
}
Run Code Online (Sandbox Code Playgroud)
我想找到一种使用 cells.AddRange 的方法,而不使用 for/while ,如果可能的话。