JavaScript-Variable: Deklarieren, Wert mit Beispiel zuweisen

Anonim

Variablen werden zum Speichern von Werten (Name = "John") oder Ausdrücken (Summe = x + y) verwendet.

Deklarieren Sie Variablen in JavaScript

Bevor Sie eine Variable verwenden, müssen Sie sie zuerst deklarieren. Sie müssen das Schlüsselwort var verwenden , um eine Variable wie folgt zu deklarieren:

var name;

Weisen Sie der Variablen einen Wert zu

Sie können der Variablen entweder beim Deklarieren der Variablen oder nach dem Deklarieren der Variablen einen Wert zuweisen.

var name = "John";

ODER

var name;name = "John";

Variablen benennen

Obwohl Sie die Variablen beliebig benennen können, ist es eine gute Programmierpraxis, den Variablen beschreibende und aussagekräftige Namen zu geben. Darüber hinaus sollten Variablennamen mit einem Buchstaben beginnen und zwischen Groß- und Kleinschreibung unterscheiden. Daher unterscheiden sich die Variablen student name und studentName, da der Buchstabe n in einem Namen unterschiedlich ist (n und N).

Versuchen Sie dies selbst:

 Variablen !!! </ title><script type = "text />var one = 22;var zwei = 3;var add = eins + zwei;var minus = eins - zwei;var multiplizieren = eins * zwei;var dividieren = eins / zwei;document.write ("Erste Nr.: =" + eins + "<br />Zweite Nr.: =" + zwei + "<br />");document.write (eins + "+" + zwei + + add + "<br />");document.write (eins + "-" + zwei + + minus + "<br />");document.write (eins + "*" + zwei + + multiplizieren + "<br />");document.write (eins + "/" + zwei + + dividieren + "<br />");</ script></ head><body></ body></ html></pre> <form class="hidden" code-box" name="sample"> Dieser Code kann bearbeitet werden. Klicken Sie zum Ausführen auf Ausführen<textarea name="codeguru"> </textarea>
<p><input type="submit" value="Lauf" style="background-color:#df5035;" color:#ffffff;"></p>


										</div>
									</article>
									
<div id="container-5533149ee6411a5f99b370c693e87966"></div>								</div>
							</div>
						</div>
					</div>
				</div>
				
<aside class="col-lg-4 sidebar sidebar--right">
	<div class="widget widget-popular-posts">
		<h2 class="widget-title">Beliebte Beiträge</h2>
		<ul class="post-list-small">
			<li class="post-list-small__item">
				<div class="post-list-small__entry clearfix">
					<div class="post-list-small__img-holder">
						<div class="thumb-container thumb-100"><a href="/8002956-inset-block" title="Einschubblock - CSS-Tricks" rel="bookmark"><img src="https://cdn.css-code.org/3177142/inset-block_css-tricks.png.webp" loading="lazy" alt="Einschubblock - CSS-Tricks" title="Einschubblock - CSS-Tricks" class="post-list-small__img--rounded" style="width:88px;height:88px" /></a></div>
					</div>
					<div class="post-list-small__body">
						<h3 class="post-list-small__entry-title"><a href="/8002956-inset-block" title="Einschubblock - CSS-Tricks" rel="bookmark">Einschubblock - CSS-Tricks 2025</a></h3>
					</div>
				</div>
			</li><li class="post-list-small__item">
				<div class="post-list-small__entry clearfix">
					<div class="post-list-small__img-holder">
						<div class="thumb-container thumb-100"><a href="/8002957-inset-block-start" title="Inset-Block-Start - CSS-Tricks" rel="bookmark"><img src="https://cdn.css-code.org/5182436/inset-block-start_css-tricks.png.webp" loading="lazy" alt="Inset-Block-Start - CSS-Tricks" title="Inset-Block-Start - CSS-Tricks" class="post-list-small__img--rounded" style="width:88px;height:88px" /></a></div>
					</div>
					<div class="post-list-small__body">
						<h3 class="post-list-small__entry-title"><a href="/8002957-inset-block-start" title="Inset-Block-Start - CSS-Tricks" rel="bookmark">Inset-Block-Start - CSS-Tricks 2025</a></h3>
					</div>
				</div>
			</li><li class="post-list-small__item">
				<div class="post-list-small__entry clearfix">
					<div class="post-list-small__img-holder">
						<div class="thumb-container thumb-100"><a href="/8002958-inset-inline" title="Inset-Inline - CSS-Tricks" rel="bookmark"><img src="https://cdn.css-code.org/3279191/inset-inline_css-tricks.png.webp" loading="lazy" alt="Inset-Inline - CSS-Tricks" title="Inset-Inline - CSS-Tricks" class="post-list-small__img--rounded" style="width:88px;height:88px" /></a></div>
					</div>
					<div class="post-list-small__body">
						<h3 class="post-list-small__entry-title"><a href="/8002958-inset-inline" title="Inset-Inline - CSS-Tricks" rel="bookmark">Inset-Inline - CSS-Tricks 2025</a></h3>
					</div>
				</div>
			</li>
		</ul>
	</div>

	<div class="widget widget-popular-posts">
		<h2 class="widget-title">Die besten Bewertungen für den Monat</h2>
		<ul class="post-list-small">
			<li class="post-list-small__item">
				<div class="post-list-small__entry clearfix">
					<div class="post-list-small__body">
						<h3 class="post-list-small__entry-title"><a href="/8226610-gaussian-kernel-in-machine-learning-kernel-methods-examples" title="Gaußscher Kernel im maschinellen Lernen: Beispiele für Kernelmethoden" rel="bookmark">Gaußscher Kernel im maschinellen Lernen: Beispiele für Kernelmethoden</a></h3>
					</div>
				</div>
			</li><li class="post-list-small__item">
				<div class="post-list-small__entry clearfix">
					<div class="post-list-small__body">
						<h3 class="post-list-small__entry-title"><a href="/8226611-tensorflow-image-classification-cnnconvolutional-neural-network" title="TensorFlow-Bildklassifizierung: CNN (Convolutional Neural Network)" rel="bookmark">TensorFlow-Bildklassifizierung: CNN (Convolutional Neural Network)</a></h3>
					</div>
				</div>
			</li><li class="post-list-small__item">
				<div class="post-list-small__entry clearfix">
					<div class="post-list-small__body">
						<h3 class="post-list-small__entry-title"><a href="/8226612-17-best-r-programming-books-2021-update" title="17 besten R-Programmierbücher (Update 2021)" rel="bookmark">17 besten R-Programmierbücher (Update 2021)</a></h3>
					</div>
				</div>
			</li><li class="post-list-small__item">
				<div class="post-list-small__entry clearfix">
					<div class="post-list-small__body">
						<h3 class="post-list-small__entry-title"><a href="/8226613-10-best-tensorflow-books-2021-update" title="10 BESTE TensorFlow-Bücher (Update 2021)" rel="bookmark">10 BESTE TensorFlow-Bücher (Update 2021)</a></h3>
					</div>
				</div>
			</li><li class="post-list-small__item">
				<div class="post-list-small__entry clearfix">
					<div class="post-list-small__body">
						<h3 class="post-list-small__entry-title"><a href="/8226614-tensorflow-autoencoder-dataset-with-deep-learning-example" title="TensorFlow Autoencoder: Datensatz mit Deep Learning-Beispiel" rel="bookmark">TensorFlow Autoencoder: Datensatz mit Deep Learning-Beispiel</a></h3>
					</div>
				</div>
			</li><li class="post-list-small__item">
				<div class="post-list-small__entry clearfix">
					<div class="post-list-small__body">
						<h3 class="post-list-small__entry-title"><a href="/8226615-tensorflow-tutorial-pdf-basics-beginners-pdf-download-now" title="Tensorflow Tutorial PDF: Grundlagen Anfänger PDF (Jetzt herunterladen)" rel="bookmark">Tensorflow Tutorial PDF: Grundlagen Anfänger PDF (Jetzt herunterladen)</a></h3>
					</div>
				</div>
			</li><li class="post-list-small__item">
				<div class="post-list-small__entry clearfix">
					<div class="post-list-small__body">
						<h3 class="post-list-small__entry-title"><a href="/privacy-policy" title="Datenschutzrichtlinie für css-code.org" rel="bookmark">Datenschutzrichtlinie für css-code.org</a></h3>
					</div>
				</div>
			</li><li class="post-list-small__item">
				<div class="post-list-small__entry clearfix">
					<div class="post-list-small__body">
						<h3 class="post-list-small__entry-title"><a href="/contacts" title="Kontakte css-code.org" rel="bookmark">Kontakte css-code.org</a></h3>
					</div>
				</div>
			</li><li class="post-list-small__item">
				<div class="post-list-small__entry clearfix">
					<div class="post-list-small__body">
						<h3 class="post-list-small__entry-title"><a href="/about-site" title="Über uns" rel="bookmark">Über uns</a></h3>
					</div>
				</div>
			</li>
		</ul>
	</div>
	
<div id="container-5533149ee6411a5f99b370c693e87966"></div>	<div class="widget widget-popular-posts">
		<h2 class="widget-title">Top Artikel</h2>
		<ul class="post-list-small">
			<li class="post-list-small__item">
				<div class="post-list-small__entry clearfix">
					<div class="post-list-small__img-holder">
						<div class="thumb-container thumb-100"><a href="/8225952-23-best-web-development-ide-2021-update" title="23 Beste Webentwicklungs-IDE (Update 2021)" rel="bookmark"><img src="https://cdn.css-code.org/2357612/23_best_web_development_ide_2021_update.png.webp" loading="lazy" alt="23 Beste Webentwicklungs-IDE (Update 2021)" title="23 Beste Webentwicklungs-IDE (Update 2021)" class="post-list-small__img--rounded" style="width:88px;height:88px" /></a></div>
					</div>
					<div class="post-list-small__body">
						<h3 class="post-list-small__entry-title"><a href="/8225952-23-best-web-development-ide-2021-update" title="23 Beste Webentwicklungs-IDE (Update 2021)" rel="bookmark">23 Beste Webentwicklungs-IDE (Update 2021) 2025</a></h3>
					</div>
				</div>
			</li><li class="post-list-small__item">
				<div class="post-list-small__entry clearfix">
					<div class="post-list-small__img-holder">
						<div class="thumb-container thumb-100"><a href="/8225954-scatter-plot-in-r-using-ggplot2-with-example" title="Streudiagramm in R mit ggplot2 (mit Beispiel)" rel="bookmark"><img src="https://cdn.css-code.org/1715684/scatter_plot_in_r_using_ggplot2_with_example.png.webp" loading="lazy" alt="Streudiagramm in R mit ggplot2 (mit Beispiel)" title="Streudiagramm in R mit ggplot2 (mit Beispiel)" class="post-list-small__img--rounded" style="width:88px;height:88px" /></a></div>
					</div>
					<div class="post-list-small__body">
						<h3 class="post-list-small__entry-title"><a href="/8225954-scatter-plot-in-r-using-ggplot2-with-example" title="Streudiagramm in R mit ggplot2 (mit Beispiel)" rel="bookmark">Streudiagramm in R mit ggplot2 (mit Beispiel) 2025</a></h3>
					</div>
				</div>
			</li><li class="post-list-small__item">
				<div class="post-list-small__entry clearfix">
					<div class="post-list-small__img-holder">
						<div class="thumb-container thumb-100"><a href="/8225955-12-best-free-virtual-machine-vm-software-in-2021" title="12 Beste KOSTENLOSE VM-Software (Virtual Machine) im Jahr 2021" rel="bookmark"><img src="https://cdn.css-code.org/6180611/12_best_free_virtual_machine_vm_software_in_2021.png.webp" loading="lazy" alt="12 Beste KOSTENLOSE VM-Software (Virtual Machine) im Jahr 2021" title="12 Beste KOSTENLOSE VM-Software (Virtual Machine) im Jahr 2021" class="post-list-small__img--rounded" style="width:88px;height:88px" /></a></div>
					</div>
					<div class="post-list-small__body">
						<h3 class="post-list-small__entry-title"><a href="/8225955-12-best-free-virtual-machine-vm-software-in-2021" title="12 Beste KOSTENLOSE VM-Software (Virtual Machine) im Jahr 2021" rel="bookmark">12 Beste KOSTENLOSE VM-Software (Virtual Machine) im Jahr 2021 2025</a></h3>
					</div>
				</div>
			</li>
		</ul>
	</div>
</aside>			</div>
		</div>
		
<footer class="footer footer--dark">
	<div class="container">
		<div class="footer__widgets">
			<div class="row">
				<div class="col-lg-4">
					<div class="widget">
						<h2 class="widget-title">Beliebte Beiträge</h2>
						<ul class="post-list-small">
							<li class="post-list-small__item">
								<div>
									<div>
										<h3 class="post-list-small__entry-title"><a href="/8222518-jmeter-gui-test-plan-and-workbench" title="JMeter-GUI: Testplan & Werkbank" rel="bookmark">JMeter-GUI: Testplan & Werkbank</a></h3>
									</div>
								</div>
							</li><li class="post-list-small__item">
								<div>
									<div>
										<h3 class="post-list-small__entry-title"><a href="/8222519-how-to-use-jmeter-for-performance-and-load-testing" title="Verwendung von JMeter für die Leistung & Lasttest" rel="bookmark">Verwendung von JMeter für die Leistung & Lasttest</a></h3>
									</div>
								</div>
							</li><li class="post-list-small__item">
								<div>
									<div>
										<h3 class="post-list-small__entry-title"><a href="/8222520-jmeter-timers-constant-gaussian-random-uniform-example" title="Jmeter-Timer: Konstante, Gaußsche Zufälligkeit, Uniform (Beispiel)" rel="bookmark">Jmeter-Timer: Konstante, Gaußsche Zufälligkeit, Uniform (Beispiel)</a></h3>
									</div>
								</div>
							</li><li class="post-list-small__item">
								<div>
									<div>
										<h3 class="post-list-small__entry-title"><a href="/8222522-how-to-use-assertions-in-jmeter-response-example" title="Verwendung von Assertions in JMeter (Antwortbeispiel)" rel="bookmark">Verwendung von Assertions in JMeter (Antwortbeispiel)</a></h3>
									</div>
								</div>
							</li><li class="post-list-small__item">
								<div>
									<div>
										<h3 class="post-list-small__entry-title"><a href="/8222523-controllers-in-jmeter-loop-simple-transaction-module-random" title="Controller in JMeter: Schleife, Einfach, Transaktion, Modul, Zufällig" rel="bookmark">Controller in JMeter: Schleife, Einfach, Transaktion, Modul, Zufällig</a></h3>
									</div>
								</div>
							</li>
						</ul>
					</div>
				</div>
				<div class="col-lg-4">
					<div class="widget">
						<h2 class="widget-title">Tipp Der Redaktion</h2>
						<ul class="post-list-small">
						<li class="post-list-small__item">
								<div>
									<div>
										<h3 class="post-list-small__entry-title"><a href="/8223683-what-is-sap-instance-and-sap-sid" title="Was ist die SAP-Instanz & SAP SID?" rel="bookmark">Was ist die SAP-Instanz & SAP SID?</a></h3>
									</div>
								</div>
							</li><li class="post-list-small__item">
								<div>
									<div>
										<h3 class="post-list-small__entry-title"><a href="/8223684-sap-r3-architecture-tutorial" title="Sap R / 3-Architektur-Tutorial" rel="bookmark">Sap R / 3-Architektur-Tutorial</a></h3>
									</div>
								</div>
							</li><li class="post-list-small__item">
								<div>
									<div>
										<h3 class="post-list-small__entry-title"><a href="/8223685-what-is-client-how-to-create-a-new-client-in-sap-scc4" title="Was ist der Kunde? So erstellen Sie einen neuen Client in SAP SCC4" rel="bookmark">Was ist der Kunde? So erstellen Sie einen neuen Client in SAP SCC4</a></h3>
									</div>
								</div>
							</li><li class="post-list-small__item">
								<div>
									<div>
										<h3 class="post-list-small__entry-title"><a href="/8223686-how-to-delete-a-client-in-sap-sm50" title="So löschen Sie einen Client in SAP SM50" rel="bookmark">So löschen Sie einen Client in SAP SM50</a></h3>
									</div>
								</div>
							</li><li class="post-list-small__item">
								<div>
									<div>
										<h3 class="post-list-small__entry-title"><a href="/8223687-how-to-lock-su01-and-unlock-su10-a-sap-user" title="So sperren Sie (SU01) & Entsperren (SU10) eines SAP-Benutzers" rel="bookmark">So sperren Sie (SU01) & Entsperren (SU10) eines SAP-Benutzers</a></h3>
									</div>
								</div>
							</li>
						</ul>
					</div>
				</div>
				<div class="col-lg-4">
					<div class="widget">
						<h2 class="widget-title">Top Artikel</h2>
						<ul class="post-list-small">
						<li class="post-list-small__item">
								<div>
									<div>
										<h3 class="post-list-small__entry-title"><a href="/8222717-mobile-apps-testing-sample-test-cases-and-test-scenarios" title="Testen mobiler Apps: Beispieltestfälle & Testszenarien" rel="bookmark">Testen mobiler Apps: Beispieltestfälle & Testszenarien</a></h3>
									</div>
								</div>
							</li><li class="post-list-small__item">
								<div>
									<div>
										<h3 class="post-list-small__entry-title"><a href="/8222718-real-device-vs-simulator-vs-emulator-testing-key-differences" title="Real Device Vs Simulator Vs Emulator Testing: Hauptunterschiede" rel="bookmark">Real Device Vs Simulator Vs Emulator Testing: Hauptunterschiede</a></h3>
									</div>
								</div>
							</li><li class="post-list-small__item">
								<div>
									<div>
										<h3 class="post-list-small__entry-title"><a href="/8222719-appium-desired-capabilities-for-android-emulator-example" title="Appium Desired Capabilities für Android Emulator (Beispiel)" rel="bookmark">Appium Desired Capabilities für Android Emulator (Beispiel)</a></h3>
									</div>
								</div>
							</li><li class="post-list-small__item">
								<div>
									<div>
										<h3 class="post-list-small__entry-title"><a href="/8222721-appium-tutorial-for-android-and-ios-mobile-apps-testing" title="APPIUM Tutorial für Android & Testen von iOS Mobile Apps" rel="bookmark">APPIUM Tutorial für Android & Testen von iOS Mobile Apps</a></h3>
									</div>
								</div>
							</li><li class="post-list-small__item">
								<div>
									<div>
										<h3 class="post-list-small__entry-title"><a href="/8222723-connect-mobile-device-with-android-debug-bridgeadb-to-usb-wifi" title="Verbinden Sie das mobile Gerät mit der Android Debug Bridge (ADB) mit USB und WLAN" rel="bookmark">Verbinden Sie das mobile Gerät mit der Android Debug Bridge (ADB) mit USB und WLAN</a></h3>
									</div>
								</div>
							</li>
						</ul>
					</div>
				</div>
			</div>
			<p>© Copyright de.css-code.org, 2025 August | 
				<a href="https://de.css-code.org/about-site" title="Über Site">Über Site</a> | 
				<a href="https://de.css-code.org/contacts" title="Kontakte">Kontakte</a> | 
				<a href="https://de.css-code.org/privacy-policy" title="Datenschutz-Bestimmungen">Datenschutz-Bestimmungen</a>.
			</p>
			
		</div>
	</div>
</footer>		
<link href="https://css-code.org/template/css/style.min.css" rel="preload" as="style" onload="this.onload=null;this.rel='stylesheet'" />	</body>
</html>