Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
261 views
in Technique[技术] by (71.8m points)

javascript - 检查值是否是JavaScript中的对象(Check if a value is an object in JavaScript)

如何检查值是否是JavaScript中的Object?

  ask by Danny Fox translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

If typeof yourVariable === 'object' , it's an object or null.

(如果typeof yourVariable === 'object'typeof yourVariable === 'object'对象或null。)

If you want to exclude null, just make it typeof yourVariable === 'object' && yourVariable !== null .

(如果要排除null,请将其类型设置为typeof yourVariable === 'object' && yourVariable !== null 。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...