null vs undefined

by willtx

JavaScript

var clientData = {};
 // var clientData =  undefined ; //Ooooops!
 //var clientData =  null; // Ooooops!

try{
	console.log("clientData.clients: ", clientData.clients);
	console.log("clientData.clients == null", clientData.clients == null);
	console.log("clientData.clients == undefined", clientData.clients == undefined);
  console.log("clientData.clients == 'undefined'", clientData.clients == 'undefined');
	console.log("clientData.clients === null", clientData.clients === null);
	console.log("clientData.clients === undefined", clientData.clients === undefined);
  console.log("clientData.clients === 'undefined'", clientData.clients === 'undefined');
}
catch(e)
{
	console.log("Ooooops!", e);
}









/* const getClients = () =>
  new Promise((resolve, reject) => {
    if (!clients) {
      return setTimeout(
        () => reject(new Error('Clients not found')),
        250
      );
    }

    setTimeout(() => resolve(clients, 250));
  });

// all
const doGetClients = async () => {
  try {
    const result = await getClients();
    console.log(result);
  } catch (error) {
    console.log(error);
  }
};

const getClient = (id) =>
  new Promise((resolve, reject) => {
    const client = clients[id];

    if (!client) {
      return setTimeout(
        () => reject(new Error('Client not found')),
        250
      );
    }

    setTimeout(() => resolve(clients[id]), 250);
  });

// by id
const doGetClient = async (id) => {
  try {
    const result = await getClient(id);
    console.log(result);
  } catch (error) {
    console.log(error);
  }
};



const clientData = await doGetClients()
if (clientData.clients == null)
  clientData.clients = [];

console.log("clients: ", clientData.clients);
*/