Basic concepts
Programming: people through the "language" that tells the computer what to do
Communication "language", people and computers, say the full "language", equivalent to write a complete program; this program tells the computer we want it to do.
"Language" (computer language) development history:
1, machine language
All binary number consisting of 1 and 0, the binary number expressing a combination of a meaning.
Because computers only recognize 1 or 0, or a combination thereof, we can only "speak" through a combination of a long string of 1's and 0's, think of all terror.
2, assembly language
By the simple English, letters or characters instead of a specific directive, which has set a good meaning.
These "simple English, letters or characters" has been equated in a computer inside and a "specific instruction", we use "simple English word
Mother or character "to" speech "on a lot easier.
These "specific instruction" is actually a combination of good writing in advance of 1s and 0s, the nature of the computer, the bottom, always known only 1s and 0s.
3, high-level language
Programming languages, high-level language is the language we now use: java, c, c ++, C #, js, pascal, python, lisp,
prolog, FoxPro, etc.,
It is no longer just "simple English, letters or characters" representing a particular instruction, but closer to natural language (the language we use), basically out
The machine's hardware system,
So that we can use more understandable way of programming.
High-level language itself is still in progress, in the end will not really completely natural language and equate?
Language two categories
Interpreted language:
Reading the line of code, and then execute once resolved, then the next line of code parsing. Such as: JS php python, are interpreted
Language.
Compiled language:
The entire contents of the implementation of the resolution. Such as: C # java C C ++, are compiled languages.
If the code is wrong, an interpreted language will run to the wrong place, then stop, compiled languages will direct error, will not be executed.
Misclassification
1, a syntax error
Format errors, such as the need uppercase lowercase place, where it is needed to use the Chinese semicolon semicolon and so on.
This type of error can not be compiled, so it is easy to find and modify.
2, logic errors
"No appropriate error", "to step error", meaning did not follow the logic go, or logical thinking problems, leading not get the desired results.
This type of error can match the syntax, the code can be compiled, it is often more difficult to find.
3, run-time error
General algorithms and programs related to this error. Or algorithm leads to memory leaks, insufficient storage space, the value of cross-border and so on.
There is also a file path not such a simple case.
Grammar, logic is correct, runtime error, if there prompted the strike, did not suggest, depending on the situation can only slowly checked ...
General function development steps
1- functional plan
2- requirements analysis
3- function development (determined data structures and algorithms)
4- function test
5- maintenance functions
on-line functions 6-
Two key points of the program
data structure:
General statement: how data is stored.
Data structure for beginners do not understand too, will be getting back to their own understanding.
algorithm:
Solution to the problem and steps.
Algorithm characteristics:
1, there is poor: the steps of an algorithm, in a limited range, can be completed within the time, the algorithm must be able to perform limited
After termination steps.
2, deterministic: each step should be to determine, rather than vague, each step must have a precise definition.
3, a plurality of input to 0, 0 refers to input initial conditions fix algorithm itself.
4, 1 to multiple outputs, the algorithm does not output is meaningless.
5, the effectiveness, feasibility, calculation "123/0 =?" There is no validity, infinite loop algorithm is not feasible.
JS Programming Fundamentals
Comment way
Single-line comments: a single line of code
// comment content
Multiline comments: for a function block
/ * Comment * content /
Identifier
It represents a certain meaning names (variables, arrays, functions, etc.).
Naming conventions
Mandatory requirements:
1, numbers, letters, underscores, the dollar sign (do not use special symbols).
2, can not begin with mathematics.
3, can not use the keywords and reserved words.
4, JS is case sensitive (case sensitive).
Soft requirements:
Wang Wen EENOW (associated therewith).
naming method
1 large hump nomenclature: capitalize the first letter of each word
Hewei HeJiaQi Wang_Jie_Yi
2, small hump nomenclature: In addition to the first one word, each word is capitalized back (recommended)
Hewei heJiaQi wang_Jie_Yi
3, snake named law: separator between each word is underlined
wang_jie_yi
4, Hungarian notation: the first to write identifier type, write identifier name
S_jie_yi
JS Features
1. interpreted *
javascript is an interpreted scripting language.
2. Object-based
javascript is an object-based scripting language, it can not only create objects, also can use an existing object.
3. Simple
javascript uses a weakly typed variable type, data type to use is not made strict requirements.
4. dynamic
javascript is an event-driven scripting language, it does not require a web server can respond to user input.
5. Cross-platform
javascript scripting language does not depend on the operating system, you need only browser support.
6. single-threaded *
javascript is single-threaded language: the same time only do a particular thing.
DOS operating system console command
dir display all the contents of directories (all the contents of the current folder)
cd enter a directory (enter a folder)
cd .. go back one level (to return to the previous folder)
cd \ back to the root directory (the current letter )
cls clear screen
Variable declaration format
Keywords identifier semicolon
ES5
var F65; is the code for a complete JS
var username;
username = "F65";
ES6 (recommended)
let F65; is the code for a complete JS
let username;
username = "F65";
const x = 5;
Note: An identifier declared const is a constant (after assignment, can not be assigned again to change it);
var and let the difference between:
1, var declare variables may be repeated, can not let (var and let a statement that a variable name is not the same line).
2, var statement can be used after the first (first use, to give default values undefined).
Variable assignment
F67 the let, F68, F69;
the let. 1 = F67, F68 =. 1, F69 =. 1;
the let = F67 = F68 = F69. 1;
one or more may be simultaneously or assignment statement.
type of data
Generally divided into two major categories of basic and complex.
Simple data types, basic data types
1, Undefined type
Only one value, undefined, expressed declared unassigned; that is, declare a variable, but not the assignment, this variable is undefined.
Note: a direct output undeclared variable also undefined, because it (the ES5) automatically make up a front variable var (not complement let), is equal to the variable declared with var.
2, Null type
Only one value, null, represents a null object pointer.
Note:
undefined is derived from the null, so to compare two values are equal, but certainly not congruent. Anyway, others given!
3, Boolean type
A most used type, there are two values are true, false. Case sensitive, True and False is the identifier, not a Boolean value.
When the data is converted to a boolean value:
4, Number type
Numeric type, represents the integer and floating point data, also referred to in some languages "double-precision value."
Value: All values, with a special value NaN (is not a Number).
F66 is not purely digital determination: isNaN (F66), returns true if the number is not a pure represented F66, F66 returns false indicates purely digital.
5, String type
Strings can, double quotes, character templates are represented by single quotes.
Output quotes:
All types and string concatenation, will give variable type is String:
NOTE: string "addition", "+" symbol will be spliced directly stitched together to give a positive or a string.
6, Symbol type
ES6 new data types, object types Symbol never equal, even when the incoming create the same value.
Used for objects to avoid in the new time, changing the original properties or methods, the use of Symbol (uniqueness) to create the key.
Complex data types, reference data types
Object refers to the type of object.
Scope
Operators
Arithmetic
Plus +
Less -
Take *
In addition to /
Modulo 2% 5% 1 obtained Number
Assignment Operators
= Let a = 3; // 3 as the value assigned to the variable a. Read as assignment operator =
+ = A + = 3; // a = a + 3; a 变为 6
- = * = / =% = = + @ and the like
Unary operators
Comparison Operators
Logical Operators
Non-! Means negated
Category negated
boolean | Corresponding negated |
Non-empty string | false |
null | true |
undefined | true |
NaN | true |
Digital non-zero | false |
Operator Precedence
Ternary operator