It is more reasonable to write a ternary expression when it is judged to be true and does not change.

for example:

getCookie ("home_voice")? True: setCookie ("home_voice", 0);

it feels strange to true. Do you have a more suitable one? Do not know whether it is feasible to give an empty string ("")?

Oct.28,2021

getCookie ("home_voice") | | setCookie ("home_voice", 0)


empty string does not work, because judging by if, empty string returns false


just use or

getCookie("home_voice") || setCookie("home_voice",0);

getCookie("home_voice")getCookie("home_voice"):setCookie("home_voice",0);

then why do you still use three yuan? If the upstairs positive solution
is really executed, then use getCookie ("home_voice") & & setCookie ("home_voice", 0)
if it is not true, use getCookie ("home_voice") | | setCookie ("home_voice", 0)
if you still want to use
getCookie ("home_voice")? Console.log ("getCookie (" home_voice ") = true"): setCookie ("home_voice", 0);
easy to debug

Menu