You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 12, 2025. It is now read-only.
classC{privatep: string;}varstr: string;varbool: boolean;varnum: number;varstrOrNum: string|number;varstrOrBool: string|boolean;varnumOrBool: number|boolean;varstrOrNumOrBool: string|number|boolean;varstrOrC: string|C;varnumOrC: number|C;varboolOrC: boolean|C;varemptyObj: {};varc: C;// A type guard of the form typeof x === s,// where s is a string literal with any value but 'string', 'number' or 'boolean',// - when true, removes the primitive types string, number, and boolean from the type of x, or// - when false, has no effect on the type of x.if(typeofstrOrC==="Object"){c=strOrC;// C}else{varr2: string=strOrC;// string}if(typeofnumOrC==="Object"){c=numOrC;// C}else{varr3: number=numOrC;// number}if(typeofboolOrC==="Object"){c=boolOrC;// C}else{varr4: boolean=boolOrC;// boolean}if(typeofstrOrC===("Object"asstring)){// comparison is OK with castc=strOrC;// error: but no narrowing to C}else{varr5: string=strOrC;// error: no narrowing to string}if(typeofstrOrNumOrBool==="Object"){letq1: {}=strOrNumOrBool;// {}}else{letq2: string|number|boolean=strOrNumOrBool;// string | number | boolean}
what is the value of strOrC at the var r2: string = strOrC