Beispiel:JS-OOP-1.html

Aus SELFHTML-Wiki
Wechseln zu: Navigation, Suche
<!DOCTYPE html>
<html lang="de">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link rel="stylesheet" media="screen" href="./Beispiel:SELFHTML-Beispiel-Grundlayout.css">  
<script>
document.addEventListener('DOMContentLoaded', function () {

const personA = new Object();
personA.name = 'Anna';
personA.alter = 31;
personA.volljährig = true;
// Ignorieren Sie die Warnung. Der Editor ist ein freies Tool und weiß es nicht besser. 
    
const personB = {
    name:  "Björn",
    age:   29,
    hobby: "Biersorten"
};
    
console.log(personB.name);
console.log(personB.hasOwnProperty("alter"));
console.log(personB);

});
 
</script>   
<style>
kbd {
	background: #f9f9f9 linear-gradient(to bottom, #eee, #f9f9f9, #eee) repeat scroll 0 0;
	border: thin solid #aaa;
	border-radius: 2px;
	box-shadow: 1px 2px 2px #ddd;
	font-family: inherit;
	font-size: 0.9em;
	padding: 0 0.5em;
}

</style>
<title>OOP in JS - 1</title>
</head>
 
<body>
  <h1>JavaScript - Objekte und ihre Eigenschaften</h1>
 
  <p>Öffnen Sie die Konsole mit <kbd>F12</kbd> und beobachten Sie die Ausgabe.<br>Erweitern Sie die letzte Ausgabe mit einem Klick auf das Dreieck!</p> 

</body>
</html>