[最佳答案] It's global, but you're accessing it at the wrong time. function refreshUser () { ... } is just a function declaration; nothing is really executed. Both logs outside that declaration run immediately, at which point the localStorage item has not been set (i.e. is null). Your wording "newUser after refreshUser()" is rather ambigious. It's indeed executed after the declaration, but newUser has not been changed at all, so both logs outside the function log null. You cannot access it at th