There are no pointers in JavaScript, only references; the pointer refers to the memory address. Being able to operate the pointer means that the program can directly operate the memory. However, when the JavaScript script is run on the web page, neither the browser nor the operating system allows JavaScript to be used. Manipulate memory, so there is no concept of pointers in JavaScript scripts, and memory can only be allocated by the browser.
The operating environment of this tutorial: Windows 10 system, JavaScript version 1.8.5, Dell G3 computer.
Are there pointers in JavaScript?
JS does not have pointers, only references.
A simple basis for judgment is: pointers can be manipulated, but JS cannot.
The pointer is actually the memory address. Being able to operate the pointer means that the program can directly operate the memory. This is very dangerous for js scripts running on the web page. Neither the browser nor the operating system will allow such a thing. occurs, so js scripts cannot have the concept of pointers and can only reference the memory allocated by the browser. As for what the physical address of this memory is, it is opaque at least to js programmers.
The example is as follows:
let a = 888 let b = a a = 999 console.log(a, b) // 999 888 对于『基本类型』的变量,a,b 相互是不影响的
However, for composite type variables, the variable actually stores a "pointer". When d=c, they Points to the same memory address, so when c changes, d also changes: let c = ['a', 'b', 'c']
let d = c d === c // true 都指向同一个『指针』呢 c[0] = 'x' console.log(d) // ["x", "b", "c"] 而这样let c = ['a', 'b', 'c'] let d = ['a', 'b', 'c'] // or 简写成 d = [...c] d === c // false 变量 d 重新赋值了呢,所以和 c 就不是一伙的啦! c[0] = 'x' console.log(d) // ["a", "b", "c"]
Expand knowledge:
Pointers are an important concept and feature in C language. They are also a difficult part of mastering C language. Pointers are memory addresses. Pointer variables are variables used to store memory addresses. Under the same CPU architecture, different types of pointer variables occupy the same storage unit length, while variables that store data vary depending on the type of data. The length of storage space occupied is also different. With pointers, you can not only operate on the data itself, but also on the variable address where the data is stored.
The pointer describes the location of data in memory, marking an entity occupying storage space and the relative distance value from the starting position of this space. In C/C language, pointers are generally considered to be pointer variables. The content of a pointer variable stores the first address of the object it points to. The object pointed to can be a variable (pointer variables are also variables), arrays, functions, etc. occupy storage space. entity.
【Related recommendations: javascript video tutorial, web front-end】
The above is the detailed content of Are there pointers in javascript?. For more information, please follow other related articles on the PHP Chinese website!

React is the preferred tool for building interactive front-end experiences. 1) React simplifies UI development through componentization and virtual DOM. 2) Components are divided into function components and class components. Function components are simpler and class components provide more life cycle methods. 3) The working principle of React relies on virtual DOM and reconciliation algorithm to improve performance. 4) State management uses useState or this.state, and life cycle methods such as componentDidMount are used for specific logic. 5) Basic usage includes creating components and managing state, and advanced usage involves custom hooks and performance optimization. 6) Common errors include improper status updates and performance issues, debugging skills include using ReactDevTools and Excellent

React is a JavaScript library for building user interfaces, with its core components and state management. 1) Simplify UI development through componentization and state management. 2) The working principle includes reconciliation and rendering, and optimization can be implemented through React.memo and useMemo. 3) The basic usage is to create and render components, and the advanced usage includes using Hooks and ContextAPI. 4) Common errors such as improper status update, you can use ReactDevTools to debug. 5) Performance optimization includes using React.memo, virtualization lists and CodeSplitting, and keeping code readable and maintainable is best practice.

React combines JSX and HTML to improve user experience. 1) JSX embeds HTML to make development more intuitive. 2) The virtual DOM mechanism optimizes performance and reduces DOM operations. 3) Component-based management UI to improve maintainability. 4) State management and event processing enhance interactivity.

React components can be defined by functions or classes, encapsulating UI logic and accepting input data through props. 1) Define components: Use functions or classes to return React elements. 2) Rendering component: React calls render method or executes function component. 3) Multiplexing components: pass data through props to build a complex UI. The lifecycle approach of components allows logic to be executed at different stages, improving development efficiency and code maintainability.

React Strict Mode is a development tool that highlights potential issues in React applications by activating additional checks and warnings. It helps identify legacy code, unsafe lifecycles, and side effects, encouraging modern React practices.

React Fragments allow grouping children without extra DOM nodes, enhancing structure, performance, and accessibility. They support keys for efficient list rendering.

The article discusses React's reconciliation process, detailing how it efficiently updates the DOM. Key steps include triggering reconciliation, creating a Virtual DOM, using a diffing algorithm, and applying minimal DOM updates. It also covers perfo

The article discusses the Virtual DOM, a key concept in web development that enhances performance by minimizing direct DOM manipulation and optimizing updates.


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

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

SublimeText3 English version
Recommended: Win version, supports code prompts!

Zend Studio 13.0.1
Powerful PHP integrated development environment

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

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