Home >Web Front-end >Front-end Q&A >Does javascript have =?

Does javascript have =?

藏色散人
藏色散人Original
2022-01-18 11:20:381991browse

Javascript has the = symbol, which represents the assignment operator and is used to assign values ​​to JavaScript variables. Its usage is as follows: "var x=10;var y=5;x=y;var demoP=document.getElementById (...)".

Does javascript have =?

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

Does javascript have =?

javascript has = symbol.

JavaScript assignment operator

The assignment operator is used to assign values ​​to JavaScript variables.

Code example:

<!DOCTYPE html>
<html>
<head> 
<meta charset="utf-8"> 
<title></title> 
</head>
<body>

<p>设置 x=10 和 y=5, 计算 x=y, 并显示结果。</p>
<button onclick="myFunction()">点我</button>
<p id="demo"></p>
<script>
function myFunction()
{
	var x=10;
	var y=5;
	x=y;
	var demoP=document.getElementById("demo")
	demoP.innerHTML="x=" + x;
}
</script>

</body>
</html>

Result:

Does javascript have =?

## Recommended study: "

js basic tutorial"

The above is the detailed content of Does javascript have =?. 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