我是学习 JavaScript 的新手。我开始掌握它的窍门,但我正在审查我从一本我正在学习的书(“Head First”)中获得的代码行,并且我有点难以理解何时使用{}
你能帮我理解吗?
function touchrock() {
if (userName) {
alert("I am glad that you have returned " + userName + "! Let's continue searching for your dream car");
} else {
userName = prompt("What is your name?");
if (userName) {
alert("It is good to meet you, " + userName + ".").onblur = setCookie;
if (navigator.cookieEnabled);
else alert("Sorry. Cookies aren't supported");
}
}
document.getElementById("lambo").src = "lamboandgirl.jpg";
document.getElementByID("lambo").onblur = setCookie;
}