RecipesChapter 2: Basic Types

Understanding Value and Type Namespaces

Recipe 2.8 from The TypeScript Cookbook

function checkPerson(person: Person) {
  return person instanceof Person;
}

checkPerson(new Person("Stefan")); // true
checkPerson({ name: "Stefan" }); // false
Open in TypeScript Playground →