http://jsbin.com/idazeg/edit#javascript,html
Can someone tell me how and why this is working?
$('#pp').click (function () {
ppp:doSomething('2'); //<=== ppp , how is JS **eating** this ?
});
http://jsbin.com/idazeg/edit#javascript,html
Can someone tell me how and why this is working?
$('#pp').click (function () {
ppp:doSomething('2'); //<=== ppp , how is JS **eating** this ?
});
ppp:
is a label statement. It's syntactically equivalent to:
ppp:
doSomething('2');
It's mostly useless here, most devs reserve them for allowing greater control over nested loops:
loop1:
for (var i = 0; i < 3; i++) { //The first for statement is labeled "loop1"
loop2:
for (var j = 0; j < 3; j++) { //The second for statement is labeled "loop2"
if (i == 1 && j == 1) {
continue loop1;
} else {
console.log("i = " + i + ", j = " + j);
}
}
}
My guess is that in the above case the ppp:
just works as a label. So there would be no difference if you remove it and only use doSomething('2');