VUE-es6,

Source: Internet
Author: User

VUE-es6,

Es6:

Es: EMCAScript 6 (es2015)

Emca: International Standards Organization

I. constants and variables

Const a = 'hello' constant const can be defined only once and cannot be repeated

The value of the variable declared by const cannot be changed, which means that once the variable is declared by const, it must be initialized immediately and cannot be left for future value assignment.

The let Command is a new command added in es6. it is used to declare variables. Its usage is similar to var. It declares variables and is only used within the code block where the let Command is located.

Let: defines a block-level scope variable.

Let it be defined in use first (no variable is promoted)

1. Differences between let and var

A,Let it be defined in use first (no variable is promoted)

B. let cannot be defined repeatedly, but can be modified.

C. var can be defined multiple times

The scope of const is the same as that of the let Command. It is only valid within the block-level scope of the declaration.

For example:

 

<! DOCTYPE html> View Code

 

Supplement:

Js data type:

String, array, number, null, undefined, boolean, object

Basic Data Type:

String, number, null, undefinedboolean

Reference Type:

Array, object

 

 

Ii. template string

A. Use it using reverse quotation marks. variables can be used in strings.

B. It can be processed as a normal string.

C. Multi-line strings can be used.

For example:

 

<! DOCTYPE html> View Code

 

III,SolutionConstruction variable

A. Array Structure assignment: Values of data elements are assigned to variables in sequence.

<!DOCTYPE html>View Code

Iv. object extension

Deconstruct can be used not only for arrays, but also for objects.

A. attributes in objects can be abbreviated

B. The methods in the object can also be abbreviated

<! DOCTYPE html> View Code

5. Function Extension

A. Default function parameters can be provided.

B. The remaining parameters can be replaced by the three vertices)

For example:

Function fun (a,... B) {} fun (, 33) then: B = []
<!DOCTYPE html>View Code

Vi. Array Extension

A. traverse the Array

(1) Use forEach Loop

If we add 1 to the original base, we will use map to traverse the array. We will use return (map () to put the function in brackets when we regret it)

For example:

arr.forEach(function (value,index) {            console.log(value);        })        var arr2 = arr.map(function (value,index) {            return value+1        })

B. determine whether an array exists.

(1) Use indexOf

(2) include the use of DES

  console.log(arr.indexOf(1000))  console.log(arr.includes(201))

C. filter the Array

 var arr4 = arr.filter(function (value,index) {            return value > 50        })        console.log(arr4);
<!DOCTYPE html>View Code
<! DOCTYPE html> Maintain Student Information

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.