JavaScript concept

Js concept:

Produced in low-speed network era, is form validation

 

With html and css produce dynamic effects upon binding (css can achieve animation effects do not use js to achieve, because the efficiency is lower than that js css)

 

js = ECMAScript +  dom   +   bom

    Syntax      Document Actions        browser object ( different browsers bom different )

DOM : the DOM entire html page is mapped into a multi-node structure (DOM Tree )

 

   dom model

    html

   / \

head body

 |  |

title  p

 |  |

'Hello' ' Hello '

 

Java and JavaScript is not related

 

javascript language features:

1. interpreted scripting language for execution

Js --- browser ( interpreted , from top to bottom, side to explain side execution )

Java ---> compile -.> Class ---> Jvm --- > binary ( machine code )

  1. Object-based language
  2. Simplicity
  3. Weak ( type ) Language

Can be used for all types var be received

5. Security

javascript is not allowed to access the local hard disk

 

In HTML use JavaScript :

type: can be seen as a language alternative property, expressed as content type codes used scripting language, the default is text / javascript

src: indicates an external file containing code to be executed

 

javascript declare variables :

Any type of variable can be used var keyword to declare .

There;

var a = ""; "" and '' equivalent

var b = 10;

There c = 9.10;

var d = new Date();

was e = true;

Global variables:

<script> defined within the

 

Local variables and global variables: internal function

 

ECMAScript does not support custom types, only 6 data types:

 

. 5 basic types of data (simple data type):

Undefined Undefined

Null null reference data types

Boolean Boolean  true / false

Number of digital type

String String Type  '' ''

. 1 Species types of reference data (complex data types):

    Object ( consisting essentially of a set of key-value pairs of unordered )

 

Null and undefined difference:

var a; // undefined (corresponding to declared only undefined)

var a = null; null reference data types

  1. Different data types
  2. The same value

 

 

Js and html can be nested with each other

 

javascript in the output : Page : Console

 

Wrote html page: document.write (....);

Written to the console : console.log (name);

Also : console.info (...);

Js elastic block:

alert pops up an alert box / message box , you can continue to access after a user clicks on the OK button.

confirm pop up a confirmation box , the user can click OK or Cancel , the confirm method accordingly returns true or false.

prompt pop-up box that allows a port (input box) entered by the user , the user input click OK , this method will return the user input .

 

Summary: JS : come to form validation, but unexpected strong ......

Six types, String ---> There are many ways, var declare the object, you can pause the code bomb box

 

Note :

    NaN data type number

    Array (the Array) data type is object

    Date (Date) data type object

    null data type is object

    Undefined variable data type is undefined

Guess you like

Origin www.cnblogs.com/wskb/p/10978646.html