On the JavaScript

   JS consists of:

       1): ECMAScript: it is the standard language JS, provides programming syntax and basic core knowledge of JS

      2): the DOM: the Document Object Model document object model, many properties available to JS and method of operation of elements in the page

       3): BOM: Browser Object Model browser object model provides a method of operating many properties browser, and these methods are stored in the Object Browser window 

 

 

 

 JS features:

    1): an interpreted language

    2): a weakly typed language - - - - declare variables with var

    3): a scripting language

    4): an object-based language - - - - js not object-oriented language, but can be simulated object-oriented thinking

    5): a dynamically typed language - - - - Code (variable) is performed only when this position, know what the variable is stored in the end, if it is the object, there are properties and methods of the object, if it is variable , is the role of variables.

                  The object is no object, as long point, by dot syntax, you can add properties and methods to the object.

 

 

 

       JS of several basic data types:

      1): number (numeric type): All figures in mathematics, 0,1, -2,3.14

          2): string (string type): JS due to which all the contents to double or single quotes

          3): boolean (Boolean): represents the antithesis of things, only two values, true, false

          4): undefined (undefined): a special data type, null values, declare variables, but no assignment, only a fixed value, undefined

          5): null (empty): represents a null value, the assignment must be manually, Null type, only one value, null

 

 

 

    Analyzing the data type of the three methods:

      . 1): typeof: Simple test data types, can distinguish only basic types: six Return Value: number, string, object, undefined, boolean, function (for null, function, object, array, using the unified will return typeof object)

     2): instanceof: determine the object is not a type: the console.log (arr the instanceof Object), i.e. the object is not determined arr type Object

     3): Object.prototype.toString.call (arr): determine which object belongs to a built-in type, which is a method Object prototype, pointing to the Object Prototype Prototype arr point, the data type is determined so as to achieve purpose

 

 

 

   JS objects:

   1): built-in objects: to provide a system, such as Math, Date, String, Array, Object

    Object constructor to create their own definition: 2): Custom Objects

    3): Object Browser: Browser comes

 

 

 

  JS objects created in three ways:

  1): to create an object literal

    2): constructor calls to create an object system

    3): Custom Constructor  

 

 

 

  Math objects: a built-in objects that have properties and methods for mathematical constants and functions, but it is not a function Math, Math all properties and methods are static

 

Math object common attributes
Math.PI PI
Math.abs() Absolute value
Math.random() Returns a random number between 0 and 1, including 0 and not including 1
Math.pow(x,y) x power of y
Math.floor() 向下取整
Math.ceil() 向上取整
Math.round() 四舍五入
Math.sqrt() 平方根
Math.sin() 正弦
Math.cos() 余弦
Math.tan() 正切
Math.asin() 反正弦
Math.acos() 反余弦
Math.atan() 反正切
Math.log() 对数
Math.max() 一组数中最大值,数与数中间用逗号隔开
Math.min() 一组数中最小值,数与数中间用逗号隔开
Math.E 自然对数

  

  

   

 

 

 

                

 

 

 

 

 

 

 

 

 

 

 

 

Guess you like

Origin www.cnblogs.com/XW-TT/p/12093300.html