JavaScript Basic Syntax

Source: Internet
Author: User

identifiers
  • first character, can be any Unicode letter (including letters in English letters and other languages), as well as the dollar sign ($ " and underscores (_ ".
  • The second and subsequent characters, in addition to Unicode letters, dollar signs, and underscores, can also be numbered 0-9 .
JavaScript has reserved words that cannot be used as identifiers: arguments, break, case, Catch, class, Const, continue, debugger, default, delete, do, else, enum, Eval, export, extends, false, finally, for, function, if, implements, import, in, instanceof, interface, let, new, NULL, Package, private, protected, public, return, static, super, switch, this, throw, true, try, typeof, Var, void, while, with, Yield
Source: http://javascript.ruanyifeng.com/grammar/basic.htmlThere are three more words that are not reserved words, but should not be used as identifiers because they have special meanings: Infinity, NaN, undefined.


The traversal of a class array object can be done using the same method as the traversal of a group object . JS User Custom Error

The following example fully reflects the try...catch...finally order of execution between the three.

function F() {  Try {    Console.Log(0);    Throw ' Bug ';  } Catch(e) {    Console.Log(1);    return true; //This sentence would have been deferred until finally the end code block was executed    Console.Log(2); //will not run  } finally {    Console.Log(3);    return false; //This sentence will overwrite the previous return    Console.Log(4); //will not run  }  Console.Log(5); //will not run}var result = F();//0//1//3result//False

In the above code,catchBefore the code block finishes executing, it executes thefinallycode block. FromcatchIntofinallyThe logo, not only hasreturnStatement, andthrowStatement.

function F() {  Try {    Throw ' something went wrong! ';  } Catch(e) {    Console.Log(' Snap to internal error ');    Throw e; //This sentence would have waited until finally ended and then executed  } finally {    return false; //Direct return  }}Try {  F();} Catch(e) {  //Does not execute here  Console.Log(' caught outer ' bogus ');}//Snap to internal error

In the code above, entercatchAfter the code block, one encountersthrowStatement, it will executefinallyCode blocks, which havereturn falsestatement, so it is returned directly, and will no longer go back to executioncatchThe remainder of the code block.

Source: http://javascript.ruanyifeng.com/grammar/error.html





From for notes (Wiz)

JavaScript Basic Syntax

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.