Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save staskuban/4578dded1955f599e2c27da57bf2bf43 to your computer and use it in GitHub Desktop.
Save staskuban/4578dded1955f599e2c27da57bf2bf43 to your computer and use it in GitHub Desktop.
ts вопросы к собеседованию
1) в каких случаях будет возвращен []?
export interface Interface {
title: string;
data: Array<string>;
id: string;
}
function foo(str:string) {
let arr = JSON.parse(str);
if (!(arr as Array<Interface>)) {
arr = [];
}
return arr
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment