The company's JS pen Test ~ You can the JS Foundation in prison. Hey heh code 1 var flag = true;
2 var flag2 = true;
3 if (flag = = True)
4 {
5 var i = 0;
6
7 J = 1;
8
9 if (Flag2 = = True)
10 {
One for (var m = 0 M < m + +)
12 {
13
14}
15}
16}
17
alert (i);
Alert (j);
Alert (m);
Output 0, 1, 10
var x = 1;
function Scopetest () {
alert (x);
}
Scopetest (); Output 1
Output 1
var x = 1;
function Scopetest () {
alert (x);
var x = ' Hello World ';
alert (x);
}
Scopetest ();
Output underfined, Hello World
var name = ' Laruence ';
function Echo ()
{
alert (name);
}
function env ()
{
var name = ' Eve ';
Echo ();
}
Env ();
Output laruence
function test (XXX) {
alert (XXX);
var xxx = 123;
function xxx () {
}
alert (XXX);
}
Test (444);
Output function xxx () {},123
Code function Jsclass () {
this. M_text = ' division element ';
this. m_element = document.createelement (' DIV ');
this. m_element.innerhtml = this. M_text;
this. M_element.attachevent (' onclick ', this. ToString);
}
JSClass.prototype.Render = function () {
Document.body.appendChild (this. m_element);
}
JSClass.prototype.ToString = function () {
Alert (this. m_text);
};
var JC = new Jsclass ();
Jc. Render (); Add Render div element
Jc. ToString (); Output Division Element
Click the div element that is added division the underfined, why.
Click the div element that is added division the underfined, why.
The This keyword in the EventHandler () method indicates that the object is the window object for IE.
This is because EventHandler is just an ordinary function, for attachevent after
The script engine has no relationship to its invocation and the Div object itself. And you can look at the caller properties of EventHandler,
It is equal to null. If we want to get a Div object reference in this method, we should use: This.event.srcElement.
Code var obj = {
i: "Test",
m: function () {
alert (this. i); //point to Obj object instance, Output value test
function b () {
alert (