当前位置:网站首页>2.13 weekly report

2.13 weekly report

2022-07-06 03:36:00 m0_ sixty-three million seven hundred and thirteen thousand two

Built-in objects

Js The language comes with , For developers , Provide necessary functions (Math Array String Date)

Math object ( Not a constructor ):Math.PI PI Math.ceil() Rounding up , That is, take the larger value

 Math.round() rounding (.5 special , Take it from the big one )    Math.abs() The absolute value Math.floor() Rounding down , That is, take the small value   

Math.random() Returns a random decimal number [0,1)

A random number between two numbers , And include these two numbers

Date object (Date): If there are no parameters , Returns the current time of the system

Common writing of parameters     Digital 2019,10,01   String type ‘2019-10-1 8:8:8’

Format date

Get the total number of milliseconds ( distance 1970.1.1)

Countdown cases :

Variable attribute differences

identical : Are used to store data

Different : Variable declaration and assignment Write the variable name directly Exist alone

      Attribute in object There is no need to declare When used, it is object . attribute

The difference between function and method

identical : To achieve a function Do something

Different : Functions are declared separately Call function name () Exist alone Method is inside the object Different calls

character string

  1. String immutable

The inner value remains unchanged , Changing the content is actually changing the address , Memory opens up a memory space

  1. Return position according to character

str.indexOf(‘ Characters to find ’, The starting position )

  1. Returns the character according to the position

charAt(index)  str.charAt(index) Return character

charCodeAt(index) str.charCodeAt(index) Return character's ASCII code

str[index] Compatibility

  1. Splice and intercept strings

Splicing : var str= ‘Andy’;

       str.concat(‘red’)

Intercept :str.substr(‘ Intercept start position ’,’ Intercept a few characters ’)

  1. Replace string Convert to array (185)

Replace :str.replace(‘a’,‘b’) hold a Replace with b    Just replace one

Convert to array :split(‘ Separator ’) String separator str.split(‘ Separator ’)

  1. Case study (183 184)

data type

Simple data type ( Basic data type , Value type )

string number Boolean undefined null( For an empty object )

Stack : Opening up space directly puts value

Complex data type ( Reference type ): adopt new Keyword created objects (Object Array Date)

First store the address on the stack ( Hexadecimal ) Then point to the data in the heap

Web APIs

Page interaction function

API:( Application programming interface ) Some predefined functions , Help us realize some function

Web API: It is a set of operating browser functions and page elements provided by the browser API

原网站

版权声明
本文为[m0_ sixty-three million seven hundred and thirteen thousand two]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202132315105442.html