Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (9.5k points)

Below is my JavaScript code:

THREEx.KeyboardState.prototype.pressed  = function(keyDesc)

{

    var keys    = keyDesc.split("+");

    for(var i = 0; i < keys.length; i++){

        var key     = keys[i];

        var pressed;

        if( THREEx.KeyboardState.MODIFIERS.indexOf( key ) !== -1 ){

            pressed = this.modifiers[key];

        }else if( Object.keys(THREEx.KeyboardState.ALIAS).indexOf( key ) != -1 ){

            pressed = this.keyCodes[ THREEx.KeyboardState.ALIAS[key] ];

        }else {

            pressed = this.keyCodes[key.toUpperCase().charCodeAt(0)];

        }

        if( !pressed)   return false;

    };

    return true;

}

Here’s the line I have the problem with:

 if( THREEx.KeyboardState.MODIFIERS.indexOf( key ) !== -1 )

Can anyone tell me what’s the meaning of != ?

1 Answer

0 votes
by (19.7k points)

When you compare 0 ==0, it returns true. For 0 == “0” it returns false. Similarly, 0! == “0” returns true, while 0! == 0 returns false. 

It means two values are compared not only by their implied value but also by their type. 

Interested in Java? Check out this Java Certification by Intellipaat.   

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
asked Apr 16, 2021 in Java by sheela_singh (9.5k points)
0 votes
1 answer
0 votes
1 answer

Browse Categories

...