Home > Web Front-end > JS Tutorial > body text

JavaScript advanced study notes organization_javascript skills

WBOY
Release: 2016-05-16 18:03:24
Original
1142 people have browsed it
1. An implementation of object-oriented js
Copy code The code is as follows:

 

2.6 types of simple data Type:
1)Undefined. A variable is defined but no value is assigned to it.
2)Null.(Reference type)
3)Number. Numeric type
 var num = 1.0 this When num is of type int, it is a floating point type only when the decimal point is not 0.
isNaN() can determine whether the passed value is of type Number,
var num = parseInt('112412aaa11'); num=112412;
4)Boolean.
5)String
6)function
Function type:
Execution environment: It is the parent environment where the current function (method) is located. For example, the execution environment of a function executed under window is window.
No block-level scope: If statements such as if do not use block scope, if, for, etc. code enclosed in curly brackets cannot form a block scope.
Var variable declaration: When using var to declare a variable, it will be added to the nearest available environment, that is, a variable defined without var is a global variable.
The declaration statement will be executed first to ensure the running of the program.
Garbage collection: When the variable object is set to null, the original object will be automatically recycled.
Attributes:
this. The execution environment where the function is located, and the scope in which the function is executed.
prototype( Prototype).

3. Complex types
Object:
The essence of the Object type is an unordered list of key-value pairs, similar to a collection, in json format.
There are many ways to create Object:
 1)var obj = new Object(); obj.name="lz"; obj.age=17;
 2)var s = {}; s .name="ly"; s.age=18;
 3)var s = {"name":"ln","age":"17"};
Methods to access the properties of the Object object:
 1)obj.name
 2)obj["name"]
Array type:
Equivalent to List, the length attribute is readable and writable (you can use this to delete array elements )
Stack method of array: (last in first out)
push() add pop() take from the top of the stack
Queue method of array: (first in first out)
shift() from Take unshift() from the end of the queue and add
from the end of the queue. Sort:
Sort() sorts the data in the array in a certain order. The parameter can be passed to a comparison method (similar to Interface) reverse() reverses
Concatenation array: concat()
var colors=["a","b"];
var newcolor=colors.concat("yellow",["c", "d"]);//colors has 5 elements.
If an array is passed in to the concate method, the array will be split and the elements will be added to the target array. If you pass in json format data, a json data will be treated as an element and added to the array.
4. Others
typeof: return true or false,
instanceof determines the type of a complex type return true or false, if it is used to determine the basic type of a value it will always return false,
eval() will parse out the parameters in eval() and insert them into the location where eval is executed. The effect is equivalent to directly writing JS code at the corresponding location.
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!