compare equality function

this will check if two values are exactly equal
function is_equal(a, b) {
  if (a === b) {
    return "Equal";
  return "Not Equal";

// you can also change this function to return true and false, but this may be just as long as actually doing the if(a === b) manually.
function is_equal_bool(a, b) {
  if (a === b) {
    return true;
  return false;

if(is_equal_bool(1, 1)) {
  console.log('1 and 1 is exactly equal');

// vs -- probably better to just use the ===
if( 1 === 1 ) {
  console.log('1 and 1 is exactly equal');
} else {
  console.log('1 and 1 is NOT exactly equal');

Other Items in javascript
Page Views

This page has been viewed 216 times.

Search Code
Search Code by entering your search text above.

This is my test area for webdev. I keep a collection of code snippits here, mostly for my reference. Also if i find a good site, i usually add it here.


Random Quote
therock Somewhere along this crazy road I learned (often times the hard way) the most important things I can do is be authentic, trust my gut, be the hardest worker in the room, celebrate the mistakes, be a grateful man and always remember that it's nice to be important, but it's more important to be nice.
The Rock