JavaScript (a) - Quick Start

1. JavaScript Overview

  • JavaScript is one of the world's most popular scripting language , is one of three Web developers must learn the language.
    (1) defines the page's HTML content
    (2) CSS page layout of the provisions of (landscaping)
    (3) conduct a web page JavaScript programming

  • A back-end qualified personnel must be proficient in JavaScript.

  • JavaScript After inserting HTML pages , by all modern browsers execution

2. History

  • ECMAScript It can be understood as a standard of JavaScript
  • The latest version has to es6 version, but most browsers just stop supporting es5 code
  • Development Environment - line environment, inconsistent versions
  • Before you write JavaScript code to be set up to support IDEA ES6 syntax , as shown below
    Here Insert Picture Description

3. Getting Started

3.1 introduces JavaScript way

(1) internal label
(2) introduced from the outside

  • The example code
    Here Insert Picture Description
  • operation result
    Here Insert Picture Description

3.2 The basic syntax

JavaScript and JavaSE largely similar, but JavaScript strict case-sensitive !

  • Variables defined type variable name = variable value;

  • Introduction browser F12 (developer debugging tools) features
    the most used features page when debugging is: element (ELements), Console (Console), the source code (Sources), network (Network) and so on.
    Here Insert Picture Description

    (1) element (Elements): used to view or modify the properties of HTML elements, CSS properties, listen for events, breakpoints (DOM breakpoint: In JavaScript debugging, we often use the breakpoints, debug fact in the DOM structure we can also use breakpoints method, which is the DOM breakpoint (DOM breakpoint))
    (2) console (console) : console generally used to perform single-use code, see the JavaScript object, view the debug log information or the exception information .
    console.log (score) represents the score in the console print variable browser, the equivalent of System.out.println ();
    (3) the source (Sources): This page allows you to view the page's HTML source code files, JavaScript source code, CSS source code, in addition to the most important thing is to debug JavaScript source code, you can add a breakpoint to the JS code and so on.
    (4) Network (Network): mainly used for viewing web pages and other header information associated with a network connection.
    Here Insert Picture Description

  • Console output
    Here Insert Picture Description

3.3 Data Type

  • Basic Type : String (String), number (Number The), Boolean (Boolean), the empty (Null), undefined (Undefined), Symbol (ES6 introduces a new type of raw data representing a unique value).

  • Reference Type : Array (Array), the object (Object), the function (Function).
    (1) String String
    string can be any text enclosed in quotation marks may be used single or double quotation marks , as 'abc' or "ABC"
    (2) Digital Number The
    JS does not distinguish between integers and decimal
    123 123 // Integer
    123.1 / / float 123.1
    1.123e3 scientific notation @
    -99 @ negative
    NaN3 // Not A Number
    Infinity // indicates infinity
    (3) Boolean Boolean
    Boolean (logical) can have only two values: true or to false
    (. 4 ) null and undefined
    null null
    undefined undefined
    (5) logical operators
    && @ and
    || or //
    ! // non
    (6) comparison operators
    =
    == equal (not the same type, the same value will be determined to be true)
    === absolutely equal (the same type, the same value, the result true)
    Note :
    ① insist on not using == Compare
    ② NaN == NaN, this is not all of equal value, including their own
    ③ can be carried out by determining whether the value is isNaN NaN3
    Here Insert Picture Description
    ④ float problem: to avoid using a float for operation, accuracy problems exist

    Here Insert Picture Description
    (7) Array array
    value must be Java objects of the same type, the JS in the object need not be the same type !
    Array subscript taken: If the out of range, there will be undefined
    Here Insert Picture Description
    (. 8) Object Object
    objects are braces , brackets array is the attribute between each separated by a comma , a need to add the last comma
    Here Insert Picture Description
    console output
    Here Insert Picture Description

4. Strict check mode

  • 'use strict'; strict inspection mode, the prevention of arbitrary JavaScript in the lead to problems arising
    and must be written in the first line of JavaScript !
    Here Insert Picture Description
  • Local variables is recommended to use let definitions
Published 62 original articles · won praise 2 · Views 2743

Guess you like

Origin blog.csdn.net/nzzynl95_/article/details/103811962