JavaScript is basic grammar

RIA (Rich Internet Applications) rich Internet applications, highly interactive, rich user experience and powerful clients.
RIA most prominent feature is the "Rich", while the core part of RIA is also reflected in the "Rich". "Rich" contains two meanings.
Rich data models: RIA technique provides a variety of data models to handle complex data manipulation, such as json, xml. Using the RIA data can be cached at the client, which can achieve a response speed than HTML-based faster, and the number of data to and from the user interface and fewer servers.
Rich interface elements: RIA technology offers a much richer than the HTML interface presentation elements, to provide users with a good experience.

1.JavaScript basic concepts
1) .JavaScript based on the object and event-driven scripting language with safety performance of
events: One thing
scripting language, not compiled, interpreted by the browser running.
Based Object: object-oriented programming
scripting languages: interpreted language, interpreted language (not compiled, finished running on the line) javascript is interpreted by the browser running
on target: it has some built-in objects can be for our use. It is not completely satisfying the three characteristics of object-oriented (encapsulation, inheritance, polymorphism). javascript rewriting, overloading, inheritance all analog. (Learn on the line)
event-driven: the full implementation of javascript is triggered by an event.

2) part: Javascript official name is "ECMAScript"
ECMAScript, describes the syntax and basic javascript objects that make up language.
Document Object Model (DOM), a descriptive approach of web content and interface.
Browser Object Model (BOM), and the browser is described a method and interactive interface.

3) .Javascript the past, present and future
history: predecessor: Livescript Netscape (Netscape) is. Netscape and Sun will jointly push it as a standard scripting language, renamed Javascript.
Status: In 2005, Ajax boom inject new blood into the JavaScript community.
Future: In the future for a long period of time is an important client program processes.

4) .Javascript role:
1 netnew; form validation 2; 3 to reduce a user operation; 4 increase security; 5 reduces maintenance workload and write code; 6 response event; 7 Games;

5) .javaScript with different Java
1.Java code must be compiled to perform, and need JavaScript compiler, simply interpreted by the browser execution;
2.Java and JavaScript though may end with customers to execute on the server, but Java multi-run the server, client and JavaScript used for;
3.JavaScript using a loose type of data, and using a strict Java data types.

6) write your first Javascript program
1. Development Tools: Any software can be written on the page of the document can be used to develop Javascript.
2. Add the Javascript code
(1) directly into the HTML document can be written in any position

Note: This section of the label does not contain any code, but the program written in another file, use the SRC external document points out, load carried out.

7) Note
action annotation 1:
Javascript annotations can be used to enhance readability.
Note 2 The use
1-line comment: // comment content
2. Multi-line comments: / * * comment content /

8) Note
1.HTML tags are not case sensitive
2.Javascript syntax is case sensitive
3. End the sanctions resolution optional (not good programming practice to omit the semicolon)
4. use English punctuation state

2. Variable: var variable name = value
js belonging to a loosely typed programming language / weakly typed
programming languages belonging precise type java / strong type
var a = 1; // value of
var b = 1.1; // value
var c = "a "; // string
var c = 'abc'; // string
var t = true; // Boolean

3. Identifier: letters, numbers, underscores and $ composition can not begin with a number can not be keywords

4. Data Types

1. The basic data types
numeric string String Boolean Boolean number
2. complex / complex data type
array object (the Math a Date String Number The Boolean)
. 1) Array An array of variable length, may store any type of data, the start index from 0
1. Definitions :
a = a new new dimension the Array var (10); a [0] = "ABC";
var a = new new the Array ( "ABC", l, 2,3);
var a = [ "ABC", 1,2, 3];
dimensional new new = A the Array var (); A [0] = new new the Array (l, 2,3);
var A = the Array new new (new new the Array (l, 2,3), the Array new new (4,2 ,. 7));
var A = [[1, 2,4], [3,5,6], [6,7, 8]];
2.length attribute length
the Join ( "-"); to "-" as the separator character connection elements of the array, return the array splice
toString (): the contents of the array translated into strings separated by commas.
a.concat (b) b is connected to the array after the array a
a.reverse () array element inversion
sort () Sort
slice (start, end) returns an array of sub-header does not index trailer

2)对象(String Math Date Number Boolean)
//String对象
	var  s=new String("abc汉字");
	//length 属性可返回字符串中的字符数目
	document.write(s.length+"<br>");
	//方法
	document.write(s.slice(-2, 5)+"<br>");//如果 start 为负 它将被替换为 length+start。
	document.write(s.slice(3, 5)+"<br>");//如果 start 为负 它将被替换为 length+start。
	document.write(s.substring(-1, 3)+"<br>");//如果 start 或 end 为负数,那么它将被替换为 0。
//Date 对象
	var d=new Date();
	document.write(d+"<br>");
	//在页面上分别打印输出年份、月份、日期、星期几、小时、分钟和秒
	document.write("年份"+d.getFullYear()+"<br>");
	document.write("月份"+(d.getMonth()+1)+"<br>");
	document.write("日期"+d.getDate()+"<br>");
	document.write("星期"+d.getDay()+"<br>");
	document.write("小时"+d.getHours()+"<br>");
	document.write("分钟"+d.getMinutes()+"<br>");
	document.write("秒"+d.getSeconds()+"<br>");
	//d.setFullYear(2016, 2, 3)
	document.write(d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate()+"  "+d.getHours()+":"+d.getMinutes()+":"+d.getSeconds()+"<br>");

	document.write(d.toLocaleDateString()+"<br>");//本地日期  2017-09-09
	document.write(d.toLocaleString()+"<br>");//本地日期和时间 2017-09-09 11:11:11
	document.write(d.toLocaleTimeString()+"<br>");//本地时间  11:11:11

//Number 
	var myNum=new Number(value);
	var myNun=Number(value)
	document.write(Number.MAX_VALUE+"<br>");
	document.write(Number.MIN_VALUE+"<br>");
//Boolean 对象
	var b=new Boolean(true);
	document.write(b.toString()+"<br>");
//Math
	document.write(Math.PI+"<br>");

  3).特殊数据类型
null空  undefined 未定义
(1)null:null 在程序中代表“无值”或者“无对象”。可以通过给一个变量赋值 null 来清除

Contents of the variable.
(2) undefined: declare a variable but never assigned it an object or property does not exist

5 implicit conversion data type
1) implicit conversion data types: direct transfer, default rule
(1) the JavaScript programming languages belonging to a loosely typed
① variable does not need to specify a data type declaration.
② variable determined by the data type of assignment.
(2) different types of data will be automatically converted in the calculation process
① string + number: number is converted to a string
② Digital Plus boolean values: true is converted to 1, false is converted to 0
③ Boolean value string +: Boolean value a string or true to false
④ Boolean Boolean +: Boolean value 0 or the value 1

2) an explicit conversion: using a method of converting
data type conversion functions (. 1)
toString () variable .toString () is converted into a string
parseInt (value) into an integer: parseInt ( "123.4abc")> 123 is not an integer: parseInt ( "abc123.4")> NaN3
parseFloat (value) is converted into decimal: parseFloat ( "123.4abc")> 123.4 instead of decimal: parseFloat ( "abc123.4")> NaN3
typeof: query the current value of the type returned String / Number / Boolean / Object
Number The () is converted into values: Number ( "123.4")> 123.4 not numeric: Number ( "123.4abc") / Number ( "abc123.4")> NaN
(2) built-in function
NaN: not a number is a Number object static properties, is very special, it is not a number, any number not equal with it, even NaN itself is not equal to NaN
isNaN (str): is not a number, determines whether the text value, false numeric, true non-numeric isNaN ( "123")> to false
the eval () string recalculate var v = "1 + 2 * 3"; eval (v)
>7

6. function key function
definitions: function function name (variable name 1, variable name 2 ...) {
function body
}
call: function name ();
can be used to return the return statement function value, but need not have a return value type

7. The scope of the variable
1 local variables: a statement in the function, must declare var
2 global variables: declare function outside, without the use of var Statement

  1. Expressions and operators
    operators are operated to complete a series of symbols. Expression is a combination of operators and operands.
    1) Arithmetic Operators + - * /% + -
    2) logical operators && ||!

    1. Assignment operator + = = = = * /% = =
      4) comparison operator>> = <<= ==! =
      5) string operators to link together two string values with +. You can also use the shorthand manner (+ =) to be expressed.
      6) Notes
      (1) to determine whether to use == equal, can not equals
      exactly equal: "="Types, values are the same.
      Not strictly equivalent:!

      For example: var A = "10"; var B = 10;
      ! A == b equal to a === b not equal to a == b equal

    (2) the difference between the i ++ ++ i and
    (3) represented by the expression i is greater than x, is less than y, should: i> x && i <y ( instead of X <i <Y)
    9. The statement
    statement is a program for implementing basic the control and operation functions
    1) if conditions are selected statement
    2) for loop
    var c = new Array ( "1 ", "2", 3,4,5,6, "abc", " the", 1.3);
    for (var I = 0; I <a.length; I ++) {
    document.write (A [I] + "
    ");
    }

    3) for (... in ...) statement
    for (var I in A) {
    document.write (A [I] + "
    ");
    }
    . 4) BREAK continue statement statement is the difference between
    A: break statement ends the current while, for loop and do ... while loop, straight out of the loop, execute the following statement cycle.
    B: the Continue statement to the end of this cycle

Guess you like

Origin blog.csdn.net/SqrsCbrOnly1/article/details/91377223