Home > Web Front-end > JS Tutorial > Notes on JavaScript language structure (1)_Basic knowledge

Notes on JavaScript language structure (1)_Basic knowledge

WBOY
Release: 2016-05-16 18:02:16
Original
923 people have browsed it

1: js supports Unicode character set, so you can name functions in Chinese.

Two: js has no initialized variables in Var, the default is undefined

Third: For variables that are neither declared nor assigned a value, if used directly, a system-level Error will be thrown. If you use typeof (typeof is a type operator) operation, regardless of whether it has been declared, a string "undefined" will be returned;

Example:

//a Undeclared

alert(typeof(a));//undefined

alert(a);//Error

Four: Arithmetic operators. " " can be used to convert a value into a string more conveniently. The specific operation is to add an empty string to the value (or not write it).

Example:

Var a=2.96;

Var b=1.0;

Alert(a ”” b);//Get the string” 2.961"

Use "-" to convert a string into a numerical value. The specific operation is to subtract a value 0 from this string

Var a="2.96";

alert(a 1);//Get the string "2.961" (force the value into a string)

alert(a-0 1);//Get the value 3.96

The following is an example I made:

Copy code The code is as follows:



js






Results:

10
51
55
5
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template