JavaScript lexical structure

JavaScript lexical structure


Lexical structure of programming language is a set of basic rules that describe how to use this language to write programs. As a basic grammar, which provides a series of grammatical structure, in JavaScript is ESMAScript (standard syntax)

character set

JavaScript is to use the Unicodecharacter set written. UnicodeIt is ASCIIand Latin-1a superset of the character set for this stage is the most perfect one utf-8, basically supports all languages in the world.

Case sensitive

JavaScript is case-sensitive language. (Simply put, all the content as long as you write js code which are case-sensitive, not comments)

HTML is not case sensitive (although XHTML is case-sensitive), so at the time of writing HTML js handling of the case must pay attention to the difference between

Unicode escapes

In some computer hardware and software, and can not display the character input Uniden Collection. In order to support programmers who use old technology, JavaScript defines a special sequence, using six ACII character table with an arbitrary 16-bit, Unicode have \ u these Unicode beginning, followed by subsequent 4 hexadecimal (0-9A-F [af]):\u00e9

Back to the top table of contents

Note

  • Single-line comments://
  • Multiline comments:/**/
  • Text Description Note:
    /**
     * make() returns a new element
     * based on the passed in tag name
     *
     * @param {String} tag
     * @return {Element} element
     */
    function make(tag) {
    
      // ...stuff...
    
      return element;
    }
    

Back to the top table of contents

The amount of direct

Data values ​​used in the program directly

12  // 整数
1.2 // 浮点数
"hello world"   //字符串 
'Hi'    // 字符串
true    // 布尔值真
false   // 布尔值假
/javascript/gi  // 正则表达式
null    // 空
[1,2,3,4,5] // 数组
{ x:1, y:2 }    // 对象

Identifier

  • Identifier: a name that is used for naming variables and functions.
    1. The identifier must begin with (aZ), (_) or ($)
    2. Subsequent characters can be letters, the change line number and dollar sign
    3. Numbers are not allowed in the position of the first letter

Reserved words

  • Some identifiers is to use their own language with syntax keywords
  • JavaScript also stored some keywords, preparing for the future
  • JavaScript also a lot of predefined global variables
  • Global variables and functions of the customer service end of the list of JavaScript
// 基础
break, delete, function;
return, typeof, case, do, if,switch,var;
catch, else, in, this, void, continue, false;
instanceof, throw, while, debugger, finally, new, true;
with, default, null, try, for();

// es5
class, const, enum, extends, super;
export, import, 

// 严格模式
implements, let, private, public, yield, interface, 
package, protected, static

// es3把Java的所有关键字都列为自己的保留字
abstract, double, goto, native, static, boolean, enum,
implements, package, super, byte, export, import, private,
synchronized, char, extends, int, protected, throws, class,
final, interface, public, transient, const, float, long, short,
valatile

// 全局变量和函数
arguments, encodeURI, Infinity, Number, RegExp, Array, encodeURIComponent,
isFinite, Object, String, Boolean, Error, isNaN, parseFloat, SyntaxError,
Date, eval, JSON, parseInt, TypeError, decodeURI, EvalError, Math,
RangeError, undefined, decodeURIComponent, Function, NaN, ReferenceError
URIError

JavaScript reserved words, there are many more than that, under normal circumstances do not need to remember, the general compiler will be specially marked

JavaScript is a programming language semicolon

Back to the top table of contents

Published 43 original articles · won praise 3 · Views 1122

Guess you like

Origin blog.csdn.net/qq_45007419/article/details/104932858