Forma e shkurtuar e kontrollit për vlerën false në JavaScript

Le të themi se tani duam të kontrollojmë vlerën e një ndryshoreje për false. Kjo mund të bëhet në mënyrën e mëposhtme:

javascriptlet test = true;

if (test === false) {
  console.log('+++');
} else {
  console.log('---');
}

Mund të shkruhet gjithashtu kod ekuivalent me mohim:

javascriptlet test = true;

if (test !== true) {
  console.log('+++');
} else {
  console.log('---');
}

Kodi i dhënë mund të rishkruhet në formë të shkurtuar si më poshtë:

javascriptlet test = true;

if (!test) {
  console.log('+++');
} else {
  console.log('---');
}
Задание 1

Rishkruani kodin e mëposhtëm duke përdorur formën e shkurtuar:

javascriptlet test = true;

if (test == false) {
  console.log('+++');
} else {
  console.log('---');
}
Задание 2

Rishkruani kodin e mëposhtëm duke përdorur formën e shkurtuar:

javascriptlet test = true;

if (test != true) {
  console.log('+++');
} else {
  console.log('---');
}
Задание 3

Rishkruani kodin e mëposhtëm duke përdorur formën e shkurtuar:

javascriptlet test = true;

if (test != false) {
  console.log('+++');
} else {
  console.log('---');
}