JS front end (a)

A, JavaScript way of introduction 

  Write code in the Script tag

< Script > 
  // here to write your JS code 
</ Script >

  Introducing additional JS file

<script src="myscript.js"></script>

Two, JavaScript language specification

  Notes (Notes is the mother of codes)

// This is a single line comment

/*
this is
Multi-line comments
*/

  Terminator

  JavaScript statements to a semicolon (;) as the terminator

Three, JavaScript language foundation

  Variable declaration

  1.JavaScript variable names can be used _, numbers, letters, $ composition, can not start with a number.

  2. declare variables var variable names use the format to be declared

var name = "Alex";
var age = 18;

  note:

  Variable names are case-sensitive.

  Recommended camel naming rules.

  Reserved words can not be used as variable names.

  supplement:

  ES6 added let command, used to declare variables. Its usage is similar to var, but variable declared valid only in the block where the let command. For example: for loop calculator is very suitable for using the let command

for (let i=0;i<arr.length;i++){...}

  ES6 add const to declare a constant. Once declared, its value can not be changed.

const PI = 3.1415 ;
PI // 3.1415

PI = 3
// TypeError: "PI" is read-only

Four, JavaScript Data Types

  JavaScript has a dynamic type

var x;   // this case x is undefined 
var x =. 1;   // this case x is a number 
var x = "Alex"   // In this case x is a string 

  Value (Number)

  J

 

Guess you like

Origin www.cnblogs.com/yljbky/p/11478353.html