Today's Question:  What's your opinion about Alibaba mooncake incident?        GIVE A SHOUT

Technical Article => Web =>  JavaScript

Some short code snippets which use all JavaScript keywords

  justjavac      2012-07-16 12:12:05      2,427    0    0

In JavaScript, keywords are reserved and cannot be used as variable or function names. For example void, function and this are JavaScript keywords, they are keywords which are reserved for special use. Here is list of the keywords in JavaScript. We also show you some short code snippets which use all the keywords in JavaScript.

void function() {//abcd
  do break;while(typeof delete this);
  for(var a;;)
  if (true)  with(null)
  try{}catch(a){}finally{} else throw new 1;
 
  switch(1 in 1 instanceof 1) {
    case false:
    default:
  }
  return;
};

Here is an improved version:

new function() {
    do break;while(typeof delete this);
    for(var a;void 0;)
        continue
    if (null)
        with(0)
    try{
        switch(1 in 1 instanceof 1) {
            case false:
            default:throw true
        }
    }catch(a){}finally{}else return 
};

You can post your code snippet if you have a shorter one.

Source : http://justjavac.iteye.com/blog/1564713

JAVASCRIPT KEYWORD CODE SNIPPET

  SAVE AS PDF   MARK AS READ   MARK AS IMPORTANT

  RELATED


  0 COMMENT


No comment for this article.


  WRITE ARTICLE

Bad load balance

By sonic0002