0

Possible Duplicate:
Javascript === vs == : Does it matter which “equal” operator I use?

whats does the === mean when working with jquery/javascript? and whats the difference between === and ==?

like i got this code

if ($this.val() != '' || ignore_empty === true) {
        var result = validateForm($this);

        if (result != 'skip') {
            if (validateForm($this)) {
                $input_container.removeClass('error').addClass('success');
            }
            else {
                $input_container.removeClass('success').addClass('error');
            }
        }
    }

and there is the ===

i just want to understand what it does and whats the difference. thanks

Community
  • 1
  • 1
Dejan.S
  • 18,571
  • 22
  • 69
  • 112

3 Answers3

1

Both are equals operators. but === is type safe.

== This is the equal operator and returns a boolean true if both the 
   operands are equal.

=== This is the strict equal operator and only returns a Boolean true 
    if both the operands are equal and of the SAME TYPE.

for example:

3 == "3" (int == string) results in true

3 === "3" (int === string) results in false

hope this helps

dknaack
  • 60,192
  • 27
  • 155
  • 202
0

== converts data to one type before comparing, === returns false if data of different types. === is preferrable.

Oleg
  • 2,733
  • 7
  • 39
  • 62
0

Loosely speaking, it provides stricter comparison.

"0" == 0 // true
"0" === 0 // false

For example...

For further info, I recommend following the link Magnus provided.

SpaceBison
  • 3,704
  • 1
  • 30
  • 44