JS native object instance explanation
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!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

How to use WebSocket and JavaScript to implement an online speech recognition system Introduction: With the continuous development of technology, speech recognition technology has become an important part of the field of artificial intelligence. The online speech recognition system based on WebSocket and JavaScript has the characteristics of low latency, real-time and cross-platform, and has become a widely used solution. This article will introduce how to use WebSocket and JavaScript to implement an online speech recognition system.

WebSocket and JavaScript: Key technologies for realizing real-time monitoring systems Introduction: With the rapid development of Internet technology, real-time monitoring systems have been widely used in various fields. One of the key technologies to achieve real-time monitoring is the combination of WebSocket and JavaScript. This article will introduce the application of WebSocket and JavaScript in real-time monitoring systems, give code examples, and explain their implementation principles in detail. 1. WebSocket technology

Introduction to how to use JavaScript and WebSocket to implement a real-time online ordering system: With the popularity of the Internet and the advancement of technology, more and more restaurants have begun to provide online ordering services. In order to implement a real-time online ordering system, we can use JavaScript and WebSocket technology. WebSocket is a full-duplex communication protocol based on the TCP protocol, which can realize real-time two-way communication between the client and the server. In the real-time online ordering system, when the user selects dishes and places an order

How to use WebSocket and JavaScript to implement an online reservation system. In today's digital era, more and more businesses and services need to provide online reservation functions. It is crucial to implement an efficient and real-time online reservation system. This article will introduce how to use WebSocket and JavaScript to implement an online reservation system, and provide specific code examples. 1. What is WebSocket? WebSocket is a full-duplex method on a single TCP connection.

JavaScript and WebSocket: Building an efficient real-time weather forecast system Introduction: Today, the accuracy of weather forecasts is of great significance to daily life and decision-making. As technology develops, we can provide more accurate and reliable weather forecasts by obtaining weather data in real time. In this article, we will learn how to use JavaScript and WebSocket technology to build an efficient real-time weather forecast system. This article will demonstrate the implementation process through specific code examples. We

JavaScript tutorial: How to get HTTP status code, specific code examples are required. Preface: In web development, data interaction with the server is often involved. When communicating with the server, we often need to obtain the returned HTTP status code to determine whether the operation is successful, and perform corresponding processing based on different status codes. This article will teach you how to use JavaScript to obtain HTTP status codes and provide some practical code examples. Using XMLHttpRequest

Golang is a powerful and efficient programming language that can be used to develop various applications and services. In Golang, pointers are a very important concept, which can help us operate data more flexibly and efficiently. Pointer conversion refers to the process of pointer operations between different types. This article will use specific examples to learn the best practices of pointer conversion in Golang. 1. Basic concepts In Golang, each variable has an address, and the address is the location of the variable in memory.

JavaScript is a programming language widely used in web development, while WebSocket is a network protocol used for real-time communication. Combining the powerful functions of the two, we can create an efficient real-time image processing system. This article will introduce how to implement this system using JavaScript and WebSocket, and provide specific code examples. First, we need to clarify the requirements and goals of the real-time image processing system. Suppose we have a camera device that can collect real-time image data
