equals (String - JavaScript)

Checks whether a string equals another object or string.

Defined in

String (Standard - JavaScript)

Syntax

equals(object:any) : boolean

equals(str:string) : boolean

Parameters Description
object Any object.
str Any string.
Return value Description
boolean True if this string equals the object or string; otherwise false.

Examples

(1) This example evaluates to true.
var cities = new String("Paris   Moscow   Tokyo");
var object = new Object("Paris   Moscow   Tokyo");
if (cities.equals(object))
	return "Equal";
else
	return "Not equal"

(2) This example evaluates to false.

var cities = new String("Paris   Moscow   Tokyo");
var object = new Object("PARIS   MOSCOW   TOKYO");
if (cities.equals(object))
	return "Equal";
else
	return "Not equal"