General shorthand checking in JavaScript

The shortened form of checking works for other data types as well. In this case, this data is first converted to a boolean type, and then compared with true. See an example:

javascriptlet test = 3;

if (test) {
  console.log('+++'); // it will work
} else {
  console.log('---');
}

In fact, the above code is equivalent to the following:

javascriptlet test = 3;

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

Without running the code, determine what will be output to the console:

javascriptlet test = 3;

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

Without running the code, determine what will be output to the console:

javascriptlet test = 'abc';

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

Without running the code, determine what will be output to the console:

javascriptlet test = '';

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

Without running the code, determine what will be output to the console:

javascriptlet test = 3 * 'abc';

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

Without running the code, determine what will be output to the console:

javascriptlet test = null;

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

Without running the code, determine what will be output to the console:

javascriptlet test = false;

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

Without running the code, determine what will be output to the console:

javascriptlet test;

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

Without running the code, determine what will be output to the console:

javascriptlet test = 0;

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

Without running the code, determine what will be output to the console:

javascriptlet test = '0';

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

Without running the code, determine what will be output to the console:

javascriptlet test = -1;

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