I have a very basic javascript function where I am splitting the string into two parts. The problem is the second part is 'null' and not null. So if function is not working properly
Please find below code and console.logs.
Why such strange behavior. Thank you in advance
  extractCredentials(request: Request): any {
    const authHeaderValue = request.headers.authorization;
    const parts = authHeaderValue.split(' ');
    const encryptedCredentails = parts[1];
    console.log(typeof encryptedCredentails) // prints string
    console.log(encryptedCredentails) // null
    console.log(encryptedCredentails.length) // prints 4
    if (encryptedCredentails == 'null') {
      console.log('null') // prints null
    }
    else {
      console.log('not null') // not executed
    }
    if (encryptedCredentails) {
      console.log('true') // true
    }
    else {
      console.log('false') // not executed
    }
    return encryptedCredentails
  }
 
     
     
    