When I am sending user id in init method, it sets the amplitude user id which is working fine, but when I call the init method without user id ( null ), it still uses the old user id. It should set the user id as null.
Is this an expected behaviour or it is a bug?
Do I need to use the setUserId method separately ? ( this one I don’t prefer as it is not a promise )
Solved
Unreliable behaviour of browser sdk init(api_key, user_id) method.

Best answer by Vishal
Alright I found out that if we want to reset the user id during initialisation we have to pass empty string in init(api_key, user_id || “”) method.
Reply
Welcome to the Amplitude Community!
If you don't have an Amplitude account, you can create an Amplitude Starter account for free and enjoy direct access to the Community via SSO. Create an Amplitude account. You can also create a Guest account below!
If you're a current customer, select the domain you use to sign in with Amplitude.
analytics.amplitude.com analytics.eu.amplitude.comor
Welcome to the Amplitude Community!
If you don't have an Amplitude account, you can create an Amplitude Starter account for free and enjoy direct access to the Community via SSO. Create an Amplitude account. Want to sign up as a guest? Create a Community account.
If you're a current customer, select the domain you use to sign in with Amplitude.
analytics.amplitude.com analytics.eu.amplitude.comor
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.