1, the = = = operator compares the value of two objects to the type of!==.
Cases:
var i = 0;var j = ' 0 '; I ==j//Truei = = = J//False
2. Events
<DivID= ' Test '> <ButtonID= "BTN"/>
<a href= "www.baidu.com" id= "BD" > Baidu </a></Div><Script>document.getElementById ('btn'). AddEventListener ('Click', Demo1); document.getElementById ('b'). AddEventListener ('Click', Demo2);
document.getElementById (' BD '). AddEventListener (' click ', Demo3);
function Demo1 (e) {alert ( " test1 " );
//e.stoppropagation ();//block event bubbling} function Demo2 () {alert ( " test2 " );}
function Demo3 (e) { alert (' test3 ');
E.preventdefault ();//block default behavior}
</ Script >
When the button is clicked, event bubbling occurs, so the event is executed from the bottom up, that is, Button-->div.
The result is: Eject test1 first, then eject Test2.
Block event bubbling: Using E.stoppropagation ();
3. How to create objects
<!-- Creating Objects - /* Method One * /people = new Object (); People.age =; People.name = ' Baohua '; document.write (' Name: ' +people.name+ ' Age: ' +people.age '); /* Method Two */ animal = {Age : $ , type: ' Dog ', voice:function () { alert (' Brak '); } }; Document.writeln (' Animal type: ' +animal.type+ ' animal Age: ' +animal.age '); Animal.voice (); /* Method Three * /function Plant (type,name) { this.type = type; this.name = name; } Flower = new Plant (' flower ', ' rose '); Document.writeln ("Plant type:" +flower.type+ "Plant Name:" +flower.name ");
JavaScript Learning Notes