Home >Web Front-end >Front-end Q&A >What are the tags in javaScript?

What are the tags in javaScript?

青灯夜游
青灯夜游Original
2021-11-24 11:24:002397browse

In javaScript, tags are names used by users when programming. They are used to name variables, constants, functions, statement blocks, etc., to establish the relationship between name and use. The first character of a legal tag must be a letter, underscore, or dollar sign, and cannot overlap with JavaScript keywords or reserved words.

What are the tags in javaScript?

The operating environment of this tutorial: windows7 system, javascript version 1.8.5, Dell G3 computer.

In javaScript, tags, also called identifiers, are names used by users when programming. They are used to name variables, constants, functions, statement blocks, etc., to establish the relationship between name and use. Identifiers usually consist of letters, numbers, and other characters.

Legal markers (identifiers) should pay attention to the following mandatory rules:

  • The first character must be a letter, underscore (_) or dollar sign ($).

  • Unicode characters can be used in other positions except the first character. It is generally recommended to use only ASCII-encoded letters, and double-byte characters are not recommended.

  • cannot have the same name as JavaScript keywords or reserved words. Otherwise, an error will be reported

    What are the tags in javaScript?

    What are the tags in javaScript?

  • ##You can use Unicode escape sequences. For example, the character a can be represented by "\u0061".

Note: Tags (identifiers) are case-sensitive

JavaScript is strictly case-sensitive, so Hello and hello are two different things of markers.

In order to avoid input confusion and grammatical errors, it is recommended to use lowercase characters to write code. Uppercase forms can be used in the following special cases:

1) It is recommended that the first letter of the constructor be capitalized. Constructors are different from ordinary functions.

Example

The following example calls the predefined constructor Date(), creates a time object, and then converts the time object into a string and displays it.

d = new Date();  //获取当前日期和时间
document.write(d.toString());  // 显示日期

2) If a marker consists of multiple words, consider using camel nomenclature - except for the first word, the first letter of subsequent words is capitalized. For example:

typeOf();
printEmployeePaychecks();

Tips:

The above are general conventions and do not constitute mandatory requirements. Users can name them according to their personal habits.

[Related recommendations:

javascript learning tutorial]

The above is the detailed content of What are the tags in javaScript?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn