gpt4 book ai didi

javascript - instanceof 自定义错误类返回 false

转载 作者:可可西里 更新时间:2023-11-01 01:43:46 38 4
gpt4 key购买 nike

<分区>

为什么这会导致 false?

'use strict';

class InvalidCredentialsError extends Error {
constructor(msg) {
super(msg);
this.name = 'InvalidCredentialsError';
}
}

const err = new InvalidCredentialsError('');

console.log(err instanceof InvalidCredentialsError);

但这会返回 true:

console.log(err instanceof Error);

enter image description here

38 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com