JavaScript · Junior · Question 62 of 75

How does "toString" in obj differ from Object.hasOwn(obj, "toString") for obj = {}?

Explanation

in checks the whole prototype chain. Object.hasOwn (a safer replacement for obj.hasOwnProperty) checks only the object itself.

Further reading

Problem with a question

JavaScript · Junior · question 62

Test yourself

Take the JavaScript · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz