Click here to Skip to main content
15,905,566 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
in this code :
JavaScript
m.port1.onmessage = function (e) {

alert(e.data);
                                 }

i want done wen e is defined !
for exam like this :

while (e == define)
{
//do more
}
Posted
Comments
SrikantSahu 23-Nov-14 2:49am    
Not sure, what is expected here.
However, if we want to check whether e is defined or not, we generally use typeof.

Example:
if(typeof e === "undefined") {
alert(1);
}
else {
alert(2);
}

1 solution

You can use this code to verify that a variable is defined (or undefined)

JavaScript
// In your case instead of "variable" you will of course use "e"
if (typeof variable === 'undefined') {
    // variable is undefined
}


Cheers,
C
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900