Home > Web Front-end > JS Tutorial > body text

Introduction to basic syntax of javaScript_basic knowledge

WBOY
Release: 2016-05-16 16:12:20
Original
919 people have browsed it

Introduction

JavaScript is a scripting language. (Scripts are text commands one by one. During execution, an interpreter of the system translates them one by one into machine-recognizable instructions and then executes them. Common scripts: batch scripts, T-SQL scripts, VBScript, etc. )

HTML is just a markup language that describes the appearance of a web page. It has no calculation or judgment capabilities. If all calculations and judgments (such as judging whether the text box is empty, judging whether the two passwords entered are consistent) are executed on the server side, the page will be It will be very slow, difficult to use, and puts a lot of pressure on the server. Therefore, it is required to be able to perform some simple operations and judgments in the browser. JavaScript is a scripting language that is executed on the browser side.

JavaScript has no direct relationship with Java. The only relationship is that JavaScript was originally called LiveScript. It later absorbed some features of Java and was upgraded to JavaScript. JavaScript is sometimes referred to as JS.

JavaScript is an interpreted language and can be run at any time without compilation.

JavaScript can be cross-platform, as long as there is a browser that supports JS. (Windows, Linux, Mac, Unix)

Grammar and precautions

1) Case sensitivity: JavaScript is strictly case sensitive. (n and N are two different variables.)

2) Weakly typed language, use var to declare variables: var num=10; num=true; OK

3) Use single quotes for strings: var msg=‘Hold on’

4) A semicolon after each sentence

5) Js comments are the same as C# and Java (//single-line comments (recommended), /* multi-line comments */ (there will be problems when using regular expressions)).

Dynamic Language

JS is a very flexible dynamic language. It is not as rigorous as static languages ​​such as C#. The JS completion function in development tools is only an auxiliary and suggestion.

Member calls that appear with "." may not work, and members that do not appear with "." may also be called, so don't worry about code problems just because "it doesn't appear at all". When writing js, you should know what members the current object has and cannot rely on smart prompts.

Dynamic languages: determine data types at runtime.

JavaScript is a dynamic type, so var i=10;i=‘variable’ is legal.

Reference external JS files

In addition to declaring JavaScript in the page, you can also write JavaScript into a separate js file and then introduce it into the page: < /script>.

The advantage of declaring to a separate js file is that multiple pages can be shared and reduce network traffic.

Note:

1) The

Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!