Home  >  Article  >  Web Front-end  >  JS native object instance explanation

JS native object instance explanation

小云云
小云云Original
2018-02-27 14:23:551423browse

1. What is an object?

In the program, the properties of an object (variables--storage data) and the methods (functions) of an object
The properties of the object and the methods of the object

2. Literal?
Symbol used to represent fixed values ​​var a = 3 literal 3 — 3
Note: The literal is the value itself
Object literal, put the key/value object in a {} to get an object literal

3. Object literal is customized by us. You can customize an object or directly use the system's built-in one. Object

4. Built-in object?
js has defined objects, you can use them directly
Array array
String string
Math Mathematical processing
Date time related

5, Array
Property: length The length of the array
method:
Concat is used to connect multiple arrays
Join Take out the array elements and connect them into a string according to the specified symbols
                                            Delete the last element of the array
Push Add an element to the end of the array
Revrser Reversing array
splice can add or delete elements
Note: You don’t need to remember what the parameters are and their functions. You only need to remember the names and functions

6 Summarize the learning methods of this chapter:
1. Do you know what is used to process this object?
2. Know what methods are available on this object and what are the functions of these methods?
3 Need to remember—Handwriting

7 String String object
charAt is used to get the character at a certain position
indexOf Determines whether a character is in a string. If so, return the position where it first appears. If not, return -1
lastIndexOf has the same function as indexOf, the difference is that it searches from the back to the front
Replace String replacement
Substr String interception, interception by number
Substring String interception, interception by position
toLowerCase Convert to lowercase
toUpperCase Convert to uppercase

8 Math object handles mathematical calculations
Abs Get the absolute value
ceil round up
flool Round down
max max value
min minimum value
Round rounding
pow x to the yth power
Random Get a random number between 0-1, including 0 but not including 1
Get a random integer between two numbers
function getRandomInt(min, max){
​ ​ //1 Convert 10-30 into a random number between 0-30? random() — 0-1
​ ​ // 2. Take an integer
       //
Return Math.floor(Math.random()*(max-min+1) + min)
}

1. What is an object?
Everything is an object
Person —- Height, weight, age In the program — Attributes (characteristics, static characteristics)
—- Eating, working, running In the program — Method (characteristics, dynamic characteristics)

在程序,某个对象的属性(变量--存储数据)  某个对象的方法(函数)

对象的属性,对象的方法

2. Literal value?
Symbol used to represent fixed values ​​var a = 3 literal 3 — 3
Note: The literal is the value itself
Object literal, put the key/value object in a {} to get an object literal

3. Object literal is customized by us. You can customize an object or directly use the system's built-in one. Object

4. Built-in object?
js has defined objects, you can use them directly
Array array
String string
Math Mathematical processing
Date Time related

5、Array
  属性: length  数组的长度
  方法:  
       concat     用来连接多个数组
       join       把数组元素拿出来,根据指定的符号连接成一个字符串
       pop        删除数组的最后一个元素
       push       在数组的末尾添加一个元素
       revrser    反转数组
       splice     可以添加或者删除元素
       注意:不用记住参数是什么,以及参数的作用,只需要记住名字和功能

6 总结这章的学习方法:
     1 知道这个对象是用了处理什么的?
     2 知道这个对象上有哪些方法,这些方法的功能是什么?
     3 需要记住—手写

7 String  字符串对象
   charAt     用来取某个位置的字符
   indexOf    判断某个字符是否在字符串中,如果在返回第一次出现的位置,如果不在返回-1
   lastIndexOf 功能和indexOf一样,区别是从后往前找
   replace    字符串替换
   substr     字符串截取, 按个数截取
   substring   字符串截取, 按位置截取
   toLowerCase  转换成小写
   toUpperCase  转换成大写

8 Math对象 处理数学计算
    abs    取绝对值
    ceil   向上取整
    flool  向下取整
    max    最大值
    min    最小值
    round   四舍五入
    pow     x的y次方
    random   获取0-1之间的随机数,包括0不包括1
    获取两个数之间的随机整数
    function getRandomInt(min, max){

       //1 把10-30 转换成 0-30之间的随机数?random() — 0-1 

        // 2.取整数 

        // 

        return Math.floor(Math.random()*(max-min+1) + min) 

    }

相关推荐:

JavaScript原生对象之Date对象的属性和方法详解_基础知识

JavaScript原生对象之Number对象的属性和方法详解_javascript技巧

JavaScript原生对象之String对象的属性和方法详解_javascript技巧

The above is the detailed content of JS native object instance explanation. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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