w3resource

JavaScript: Return true if the specified value is null, false otherwise

JavaScript fundamental (ES6 Syntax): Exercise-196 with Solution

Write a JavaScript program that will return true if the specified value is null, false otherwise.

  • Use the strict equality operator to check if the value of val is equal to null.

Sample Solution:

JavaScript Code:

//#Source https://bit.ly/2neWfJ2 
const isNull = val => val === null;
console.log(isNull(null)); 
console.log(isNull(123));

Sample Output:

true
false

Pictorial Presentation:

JavaScript Fundamental: Return true if the specified value is null, false otherwise.
JavaScript Fundamental: Return true if the specified value is null, false otherwise.

Flowchart:

flowchart: Return true if the specified value is null, false otherwise

Live Demo:

See the Pen javascript-basic-exercise-196-1 by w3resource (@w3resource) on CodePen.


Improve this sample solution and post your code through Disqus

Previous: Write a JavaScript program to check if a given argument is a number.
Next: Write a JavaScript program to check if a string is lower case or not.

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.



Follow us on Facebook and Twitter for latest update.