Javascript pour les développeurs C#
-
Upload
microsoft -
Category
Technology
-
view
351 -
download
4
Transcript of Javascript pour les développeurs C#
AMBIENT INTELLIGENCEAMBIENT INTELLIGENCE
tech days•
2015
#mstechdays techdays.microsoft.fr
Application & Digital
Communication & RSE
Business Intelligence
Integration & MDM
Client Relation Focus
Microsoft AzureParis-Lyon-Genève
#mstechdays techdays.microsoft.fr
tech.days 2015#mstechdaysSESSION
tech.days 2015#mstechdaysSESSION
tech.days 2015#mstechdaysSESSION
tech.days 2015#mstechdaysSESSION
tech.days 2015#mstechdaysSESSION
tech.days 2015#mstechdaysSESSION
•
•
•
•
•
•
tech.days 2015#mstechdaysSESSION
tech.days 2015#mstechdaysSESSION
tech.days 2015#mstechdaysSESSION
callCount
callCount
current
Le contexte du this
a changé…
La variable current
sera toujours égale
à
toto[toto.length-1]
Le contexte du this
a changé…
tech.days 2015#mstechdaysSESSION
tech.days 2015#mstechdaysSESSION
tech.days 2015#mstechdaysSESSION
tech.days 2015#mstechdaysSESSION
•
•
function inutile(){if (true) {var toto = "titi";
}
// On a accès sans problème à la variable 'toto'console.log(toto);
function whatever() {var foo = "bar";
}
// L'accès à la variable 'foo' est impossibleconsole.log(foo);
}
tech.days 2015#mstechdaysSESSION
document.getElementById("monElement").addEventListener("click", function ()
{
// Exemple classique où 'this' désigne l'élément du DOM
var nomDuNoeud = this.tagName;
});
tech.days 2015#mstechdaysSESSION
function Foobar() {
var that = this;
document.getElementById("monElement").addEventListener("click", function () {
// Ici 'this' désigne le nœud du DOM qui a levé l’évènement
// Mais 'that' désigne le contexte de la fonction de niveau supérieur
});
}
tech.days 2015#mstechdaysSESSION
function Foobar(a, b, c) {
var context = this;
}
Foobar.apply("Mon super contexte", [ 1, 2, 3 ]);
Foobar.call("Mon super contexte", 1, 2, 3);
var f = Foobar.bind("Mon super contexte");
f(1,2,3);
tech.days 2015#mstechdaysSESSION
tech.days 2015#mstechdaysSESSION
tech.days 2015#mstechdaysSESSION
tech.days 2015#mstechdaysSESSION
tech.days 2015#mstechdaysSESSION
tech.days 2015#mstechdaysSESSION
tech.days 2015#mstechdaysSESSION
tech.days 2015#mstechdaysSESSION
tech.days 2015#mstechdaysSESSION
let
(r) =>
variable dont le
scope est au niveau
du bloc
Arrow function : Callback
qui préserve la
signification du « this »
tech.days 2015#mstechdaysSESSION
tech.days 2015#mstechdaysSESSION
tech.days 2015#mstechdaysSESSION
tech.days 2015#mstechdaysSESSION
tech.days 2015#mstechdaysSESSION
http://gleborgne.github.io/javascript4csharp/
tech.days 2015#mstechdaysSESSION
tech.days 2015#mstechdaysSESSION
MERCI POUR VOTRE ATTENTION !
Guillaume Leborgne
@gleborgne
tech days•
2015
#mstechdays techdays.microsoft.fr
© 2015 Microsoft Corporation. All rights reserved.
tech days•
2015
#mstechdays techdays.microsoft.fr