This is nothing to do with context. Once you run flow.get('test') then you just have a javascript variable, so you can use typeof just the same as you would for any other variable.
What do you want to do when it is undefined? If you just want to give it a default value then you can use let test = flow.get('test') ?? some_default_value
That will set test to the default value if it does not defined (or is null).
Ah "??" My lack of experience with JavaScript syntax bites me again. The lack of examples show flow variables in use versus a simple variable, implied to me that there was something special about... var A = flow.get('test') versus B = function() or such... which now seems nutty, but late last night? Well. But flow... is just what behind the curtain an object? Not a variable. Where 'get' is a JavaScript accessor I think it is called? Thanks for the tip on '??'... never seen that in Python! LOL.
The ?? operator is a fairly recent addition to javascript.
A variable is just a reference to a javascript object, or a javascript simple value. In the statement let test = flow.get('test') ?? some_default_value
you are right that flow.get("test") is not literally a js variable, as it is not stored under an accessible name, it is the object, or value that the variable test will reference. However, when writing code, the syntax for using myVariable in an expression is exactly the same as using flow.get('test').