Table of Contents
1. Object type" >1. Object type
3. Date type" >3. Date type
4, RegExp type" >4, RegExp type
5. Function type" >5. Function type
6. Basic packaging types" >6. Basic packaging types
7. Single built-in object" >7. Single built-in object
Home Web Front-end JS Tutorial What are reference types in javascript

What are reference types in javascript

Jun 15, 2021 pm 03:32 PM
javascript reference type

The reference types in JavaScript are: 1. Object type; 2. Function type; 3. Array type; 4. RegExp type; 5. Date type; 6. Basic packaging type; 7. and single built-in type. Object(Global, Math).

What are reference types in javascript

The operating environment of this tutorial: Windows 7 system, JavaScript version 1.8.5, Dell G3 computer.

1. Object type

Object is also the most commonly used type in ECMAScript

2.Array type

Detect array if (value instanceof Array) { }

Conversion method, all objects have toLocaleString(), toString() and valueOf() methods

Stack method push () and pop() shift() and push() unshift() and pop()

Reordering method reverse() and sort()

Operation method concat() slice() splice()

Position methods indexOf() and lastIndexOf()

Iteration method every() filter() forEach() map() some()

Merge method reduce () and reduceRight()

3. Date type

var now = new Date();

Create a date based on a specific date and time Objects Date.parse() and Date.UTC().

Inherited methods toLocaleString(), toString() and valueOf()

Date formatting methods toDateString() toTimeString() toLocaleDateString() toLocaleTimeString() toUTCString()

Date/time component method getTime().............getMilliseconds().....

4, RegExp type

ECMAScript supports regular expressions through the RegExp type.

var expression = / pattern / flags ;

g: Indicates a global pattern, that is, the pattern will be applied to all strings, rather than immediately when the first match is found

Stop;

i: Indicates case-insensitive mode, that is, ignoring the case of patterns and strings when determining matches;

m : Indicates multiline mode, that is, when reaching the end of a line of text, it will continue to search whether there is an item matching the pattern

in the next line.

RegExp instance attribute

global: Boolean value, indicating whether the g flag is set.

ignoreCase: Boolean value, indicating whether the i flag is set.

lastIndex: Integer, indicating the character position to start searching for the next match, starting from 0.

multiline: Boolean value indicating whether the m flag is set.

source: The string representation of the regular expression, returned in literal form rather than the string pattern passed in the constructor.

RegExp instance method

exec()

5. Function type

Each function is an instance of the Function type. And they all have the same properties and methods as other reference types

Inside the function, there are two special objects: arguments and this.

Because the value of this is not determined before the function is called, this may refer to different objects during code execution. When called in the global scope, this refers to the global object window;

Each function contains two properties: length and prototype.

6. Basic packaging types

In order to facilitate the operation of basic type values, ECMAScript also provides 3 special reference types: Boolean, Number and

String.

In addition to the inherited methods, the Number type also provides some methods for formatting numeric values ​​into strings.

Among them, the toFixed() method will return the string representation of the value according to the specified decimal places, for example:

var num = 10;

alert(num.toFixed( 2)); //"10.00"

Another method that can be used to format values ​​is toExponential(), which returns the value expressed in exponential notation (also called e notation)

The string form of a numerical value

The two methods used to access specific characters in a string are: charAt() and charCodeAt();

String operation methods: concat() slice() , substr() and substring() indexOf() and lastIndexOf() trim()

toLowerCase(), toLocaleLowerCase(), toUpperCase() and toLocaleUpperCase()

match() search( ) replace() split() localeCompare() fromCharCode()

alert(String.fromCharCode(104, 101, 108, 108, 111)); //"hello"

7. Single built-in object

ECMA-262 defines built-in objects as: “Objects provided by ECMAScript implementations that do not depend on the host environment

Global Object

Global (global) object can be said to be the most special object in ECMAScript, because no matter which angle you look at it,

This object is Exists. The Global object in ECMAScript is, in a sense, defined as an ultimate "catch-all object". In other words, properties and methods that do not belong to any other object are ultimately Its properties and methods. In fact, there is no full

Local variables or global functions; all properties and functions defined in the global scope are properties of the Global object. The functions

introduced earlier in this book, such as isNaN(), isFinite(), parseInt() and parseFloat(), are actually all methods of the Global

object. In addition to this, the Global object also contains some other methods.

1. URI encoding method

The encodeURI() and encodeURIComponent() methods of the Global object can encode URIs (Uniform Resource

Identifiers, universal resource identifiers). In order to be sent to the browser

2. eval() method

Math object

min() and max() methods Math.ceil() , Math.floor() and Math.round()

The Math object also contains other methods related to completing various simple or complex calculations

[Recommended learning:javascript advanced tutorial

The above is the detailed content of What are reference types in javascript. For more information, please follow other related articles on the PHP Chinese website!

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to implement an online speech recognition system using WebSocket and JavaScript How to implement an online speech recognition system using WebSocket and JavaScript Dec 17, 2023 pm 02:54 PM

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 implementing real-time monitoring systems WebSocket and JavaScript: key technologies for implementing real-time monitoring systems Dec 17, 2023 pm 05:30 PM

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

How do generic functions handle pointers and reference types in Golang? How do generic functions handle pointers and reference types in Golang? Apr 16, 2024 pm 04:06 PM

When a generic function handles pointer types in Go, it will receive a reference to the original variable, allowing the variable value to be modified. Reference types are copied when passed, making the function unable to modify the original variable value. Practical examples include using generic functions to compare strings or slices of numbers.

How to use JavaScript and WebSocket to implement a real-time online ordering system How to use JavaScript and WebSocket to implement a real-time online ordering system Dec 17, 2023 pm 12:09 PM

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 implement an online reservation system using WebSocket and JavaScript How to implement an online reservation system using WebSocket and JavaScript Dec 17, 2023 am 09:39 AM

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 forecasting system JavaScript and WebSocket: Building an efficient real-time weather forecasting system Dec 17, 2023 pm 05:13 PM

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

Simple JavaScript Tutorial: How to Get HTTP Status Code Simple JavaScript Tutorial: How to Get HTTP Status Code Jan 05, 2024 pm 06:08 PM

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

How to use insertBefore in javascript How to use insertBefore in javascript Nov 24, 2023 am 11:56 AM

Usage: In JavaScript, the insertBefore() method is used to insert a new node in the DOM tree. This method requires two parameters: the new node to be inserted and the reference node (that is, the node where the new node will be inserted).

See all articles