Le 23/05/2012 22:30, David Herman a écrit :
- I will be redoing the entire wiki to focus on community first, committee
second, and to make the big picture clearer
I know writters don't have always time but maybe adding more examples
and simple ones (even not reflecting the whole picture) in the strawmans
would help a lot. For example the fat arrow strawman is very condensed
for what it brings and it took some time before I start understanding
what the soft binding strawman was about. Example of simple examples
(hope this is correct) :
Soft binding :
var o={
msg:'I am o',
log:console.log(this.msg)
}
var o2={
msg:'I am o2'
}
o2.log=o.log;
o2.log(); //"I am o"
//without soft binding it should be "I am o2"
Lexical this (and dynamic this) :
var test='aaa';
var o={test:'bbb'};
var o2={test:'ccc'};
//without lexical this
o.m=function() {var self=this; var func=function()
{console.log(this.test+' '+self)};func()};
var f=o.m;
o2.m=o.m;
o.m(); //aaa bbb
//this.test is not o.test
o2.m(); //aaa ccc
//this.test is not o2.test
f(); //aaa aaa
//with lexical this
o.m=function() {var self=this; var func=()=>console.log(this.test+'
'+self);func()}
var f=o.m;
o2.m=o.m;
o.m(); //bbb bbb
//this.test is o.test
//lexical |this| is associated to dynamic |this| outside func
//you don't need the var self=this statement
o2.m(); //ccc ccc
//same as above
f(); //aaa aaa
//other example
o.m=()=>{console.log(this.test)};
var f=o.m;
o2.m=o.m;
o.m(); //bbb
f(); //bbb
//should be aaa if no lexical this
o2.m(); //bbb
//should be ccc if no lexical this
--
jCore
Email : [email protected]
Web : www.jcore.fr
Webble : www.webble.it
Extract Widget Mobile : www.extractwidget.com
BlimpMe! : www.blimpme.com
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss