Understanding Parameters1. The number of command parameters does not have to be the same as the actual number of parameters, but you need to know the actual number of parameters can be obtained with arguments.length. 2.arguments objects can be used in conjunction with command parameters and can even be interchanged. the value of a 3.arguments object is always synchronized with the value of the corresponding command parameter, but the same value does not mean that the memory space is the same, which is a one-way effect and can only be arguments affect command parameters. 4. In strict mode, the arguments cannot be assigned a value. 5.ECMAScript only has a value pass, not a reference pass. values for base types and reference typesThe base type represents some simple data segments, and the reference type represents objects with multiple values1. For values of reference types, you can dynamically add, delete, modify properties, and methods. 2. The basic type of replication is actually the process of re-assigning the new value, while the reference type copy is given a new pointer referencing the same object. Passing Parametersall parameters of a function can only be passed by value, and the basic type passes the parameter, which is actually the value copy; The reference type passes the parameter, which is actually the delivery address. execution Environment and scopedefines a scope for a variable or function and has access to other data, which determines their behavior (Global environment, function environment). 1. The scope chain of variables ensures an orderly access to variables and functions that the execution environment has access to. 2. The interior can be accessed externally, but external cannot be accessed internally. 3. There is no block-level scope, generally other languages are surrounded by curly braces {} block-level code, also a scope, and ECMAScript will not think so. 4. The local replaces the identifiers in the parent environment. Garbage Collectionhas an automatic garbage collection mechanism, which is to find variables that are no longer in use and release their memory. Collection Policy1. Mark Clear, Tag variables, record his execution flow2. Reference count, the number of references is 0 o'clock, the first to reclaim memory after release (Ps. Easily caught in a circular reference, causing memory to never be recycled, causing a memory leak when serious). Managing Memoryto conserve system memory, save the necessary data for code execution, and once the data is no longer useful, it should be set to null, called dereferencing. the so-called dereference, which is to let the value out of the execution environment, so that the garbage collector can be recycled. Reference typea data structure, similar to a class in C + +, but does not have an interface supported by a class, also known as an object definition. var person = new Object ();where person is called an instance of an objectobject () is a constructor1.Object type, most commonly used, however there is no actual function2.Array type, each item of an array can hold a different value, the size can also be dynamically adjusted; the length of the array is always the last item + 1, (counting from 0)JavaScript functionsDefining Functionsfunction name () {function body;}sensitive to caseThe function is actually an object, and the function is an instance of the function type, which is the pointerno overloading mechanism (in-depth understanding)If you create two functions of the same name at the same time, you will see that the latter function overwrites the previous
<span style= "FONT-SIZE:14PX;" >function addnumber (num) {return num+100;} function Addnumber (num) {return num+200;} Alert (Addnumber);</span>
think about it, what's the result? 200? 300? as a worthwhile functionThe function name itself is a variable, so it can be used as a value. function Callsomefunction (somefunction,somearguments) {return someFunction (somearguments);}function declarations and function expressionsThe parser takes the lead in reading the function declaration and is available before executing the code, and the function expression is interpreted only if the line of code where the execution resides is executed. built-in objectsall things, including strings, numbers, arrays, etc., with attributes and methodsAllow custom Objects(1) Defining and creating an object instance(2) using functions to createpeople = new Object (); people.name = "L";people.age = " a";people ={
name = "L";Age =;}function People (name,age) {this.name = name;this,age = age;}son = new people ();String Object
Method description
|
function
|
return value
|
Find string
|
IndexOf ()
|
Returns the index location where the string is located
|
Content Matching
|
Match ()
|
Match not successful, return null
|
Replace content
|
Replace ()
|
The new string
|
Convert case
|
toUpperCase ()/tolowercase ()
|
The new string
|
Convert an array
|
Split ()
|
|
Array Objectuse a separate variable name to store a series of valuesarray access, specifying the array name and index number to access the specified elementconcat () merging arrayssort () sortingadd element at end of push ()Revese () array inversion
Math Objectperform common arithmetic tasksround () roundingrandom () returns the number of 0~1 betweenthe value of the random number =math.floor (Math.random () * The total number of possible values + the first possible value);If a random number is found from a non-numeric array, a function selectform (start value, end value) is used.max () highest valuemin () minimum valueABS () absolute value
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Run, my JavaScript (2)