What happens in javascript: null undefined " "
File 1: null_undefined.html
File 2: null_undefined.js
1
null_undefined.html
【See article comment 1】
null_undefined.js
var test = function()
{
alert(window.aiter2008);
alt(("test_text1111"));
var testText = ("test_text").value; // No element was entered in the test_text input box
alert(testText==""); //true
alert(testText==null); //false
}
This test can be concluded:
There is no specified variable in an object, but to use it, undefined will appear
The result of elements not found in Html is: null
Some elements in Html, but do not have any value. The result of searching through ("") is: " "; not null
2 null_undefined.html file remains unchanged
null_undefined.js
var test = function()
{
var testText = ("test_text");
var testName = ;
var testUn = testText.name11;
alert("test_text's name::"+testName); // test_text's name:: test_text
alert("test_text's name11:::"+testUn); // test_text's name11:::undefined
}
in conclusion
An object does not have an attribute, the call will appear: undefied This is the same as calling the aiter2008 attribute of the window
Previous page123Next pageRead the full text