This section provides information about changes to the equality operators and the new delete operator.
If the <SCRIPT> tag uses LANGUAGE=JavaScript1.2, the equality operators (== and !=) work differently. This section describes how the equality operators work without LANGUAGE=JavaScript1.2 and how they work with LANGUAGE=JavaScript1.2. For instructions on writing code to convert strings and numbers, see Data Conversion at the bottom of this page.
The following describes how the equality operators (= = and !=) worked in previous versions of JavaScript and how they work in JavaScript 1.2 when LANGUAGE=JavaScript1.2 is not used in the <SCRIPT> tag. Note that if LANGUAGE=JavaScript, and LANGUAGE=JavaScript1.1 are used, the equality operators maintain their previous behavior.
If LANGUAGE=JavaScript1.2 is used in the <SCRIPT> tag, the equality operators (= = and != ) behave as follows:
This approach avoids errors, maintains transitivity, and simplifies the language.
To write JavaScript code that converts strings to numbers and numbers to strings in the different versions of Navigator, follow these guidelines:
(("" + 3)=="3")
(("3"-0)==3)
var x = 3 String(x) = "3"
var x = "3" Number(x) = 3
The following example demonstrates the = = operator with different <SCRIPT> tags.
<HTML>
<SCRIPT> document.write("3" == 3); </SCRIPT> <BR> <SCRIPT> document.write(("3"-0) == 3); </SCRIPT> <BR>
<SCRIPT LANGUAGE="JavaScript"> document.write("3" == 3); </SCRIPT> <BR> <SCRIPT LANGUAGE="JavaScript1.1"> document.write("3" == 3); </SCRIPT> <BR> <SCRIPT LANGUAGE="JavaScript1.2"> document.write("3" == 3); </SCRIPT> <BR> <SCRIPT LANGUAGE="JavaScript1.2"> document.write(("3"-0) == 3); </SCRIPT> <BR> <SCRIPT LANGUAGE="JavaScript1.2"> document.write(String(3) == "3"); </SCRIPT> <BR>
</HTML>
The output from the above is:
true
true
true
true
false
true
true
Core operator. Deletes an object's property or an element at a specified index in an array.
delete objectName.property
delete objectname[index]
property is any existing property.
index is an integer representing the location of an element in an array.
If the deletion succeeds, the delete operator sets the property or element to undefined and returns true; otherwise, it returns false.