Skip to content

Commit 18cee86

Browse files
committed
feat: update solutions to lc problems: No.2618
1 parent 0918736 commit 18cee86

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

solution/2600-2699/2618.Check if Object Instance of Class/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ Dog 是 Animal 的子类。因此,Dog 对象同时是 Dog 和 Animal 的实例
5959

6060
```ts
6161
function checkIfInstanceOf(obj: any, classFunction: any): boolean {
62-
if (classFunction == null) {
62+
if (classFunction === null || classFunction === undefined) {
6363
return false;
6464
}
65-
while (obj != null) {
65+
while (obj !== null && obj !== undefined) {
6666
const proto = Object.getPrototypeOf(obj);
6767
if (proto === classFunction.prototype) {
6868
return true;

solution/2600-2699/2618.Check if Object Instance of Class/README_EN.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ Dog is a subclass of Animal. Therefore, a Dog object is an instance of both Dog
5353

5454
```ts
5555
function checkIfInstanceOf(obj: any, classFunction: any): boolean {
56-
if (classFunction == null) {
56+
if (classFunction === null || classFunction === undefined) {
5757
return false;
5858
}
59-
while (obj != null) {
59+
while (obj !== null && obj !== undefined) {
6060
const proto = Object.getPrototypeOf(obj);
6161
if (proto === classFunction.prototype) {
6262
return true;

solution/2600-2699/2618.Check if Object Instance of Class/Solution.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
function checkIfInstanceOf(obj: any, classFunction: any): boolean {
2-
if (classFunction == null) {
2+
if (classFunction === null || classFunction === undefined) {
33
return false;
44
}
5-
while (obj != null) {
5+
while (obj !== null && obj !== undefined) {
66
const proto = Object.getPrototypeOf(obj);
77
if (proto === classFunction.prototype) {
88
return true;

0 commit comments

Comments
 (0)