Home  >  Article  >  Web Front-end  >  A brief discussion on pointers and addresses in JavaScript_javascript skills

A brief discussion on pointers and addresses in JavaScript_javascript skills

WBOY
WBOYOriginal
2016-05-16 15:48:551059browse

Personal understanding: A pointer is just an index pointing to memory; and an address is the exact location in memory.

The following is a small example of pointers and addresses in functions:

function sum(num1,num2){
return num1+num2;
}
alert(sum(10,10));  //20
var anotherSum=sum;
alert(anotherSum(10,10));  //20
sum=null;
alert(anotherSum(10,10));  //20

Note: Using a function name without parentheses is to access the function pointer, not to call the function, so sum and anotherSum point to the same function, that is, sum=null; does not affect anotherSum;

The above is the entire content of this article, I hope you all like it

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