Use instanceof rather than typeof -- more accurate.