Use of Null


#1

Where do we need to use Null datatypes?


#2

Well, for example in a database where we have a field which isn’t required.

or MDN this example:

function getVowels(str) {
  var m = str.match(/[aeiou]/gi);
  if (m === null) {
    return 0;
  }
  return m.length;
}

console.log(getVowels('sky'));

re.match (which does pattern matching), returns null when there is no match.

null certainly has it uses, which you will see as you continue programming


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.