DOCTYPE HTML
DOCTYPE HTML
DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
</head>
<body>
<p id="output"></p>
<script>
document.getElementById("output").innerHTML = JSON.stringify(myArray);
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
</head>
<body>
<p id="output"></p>
<script>
let myObject = {
firstName: "Sukruthi",
lastName: "KC",
age: 22,
isMale: false
};
document.getElementById("output").innerHTML = JSON.stringify(myObject);
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
</head>
<body>
<p id="output"></p>
<script>
let myObject = {
firstName: "Sukruthi",
lastName: "KC",
age: 22,
address: {
city: "Bengaluru",
state: "Karnataka",
zip: "12345"
};
document.getElementById("output").innerHTML = JSON.stringify(myObject);
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
</head>
<body>
<pre>
<note>
<to>Shubha</to>
<from>Sukruthi</from>
<heading>Reminder</heading>
</note>
</pre>
</body>
</html>
<!DOCTYPE xml>
<html>
<head>
<style>
xml {
font-size: 16px;
color: #333;
element {
font-size: 14px;
font-weight: bold;
color: #555;
margin-bottom: 10px;
attribute {
font-size: 12px;
font-style: italic;
color: #777;
</style>
</head>
<body>
<xml>
<element>
<attribute name="id">1</attribute>
<attribute name="type">book</attribute>
<author>J.R.R. Tolkien</author>
</element>
</xml>
</body>
</html>
Math Object
<!DOCTYPE html>
<html>
<head>
<title>JavaScript Math</title>
</head>
<body>
<script>
document.write(Math.abs(-5));
document.write("<br>");
document.write(Math.ceil(3.14));
document.write("<br>");
document.write(Math.floor(3.14));
document.write("<br>");
document.write(Math.max(1,5,10));
document.write("<br>");
document.write(Math.min(1,5,10));
</script>
</body>
</html>
Output
Date Object
<!DOCTYPE html>
<html>
<head>
<title>date objects</title>
</head>
<body>
<script>
const now=new Date()
document.write(now.getDate());
document.write("<br>");
document.write(now.getMonth());
document.write("<br>");
document.write(now.getMinutes());
document.write("<br>");
now.setDate(20);
document.write(now.getDate());
document.write("<br>");
now.setMonth(4);
document.write(now.getMonth());
</script>
</body>
</html>
Output
Number Object
<!DOCTYPE html>
<html>
<head>
<title>JavaScript Number Objects</title>
</head>
<body>
<script>
document.write("JavaScript Number Objects")
document.write("<br>");
const num=42;
document.write(num.toExponential(2));
document.write("<br>");
document.write(num.toFixed(2));
document.write("<br>");
document.write(num.toString());
document.write("<br>");
document.write(num.toPrecision(4));
document.write("<br>");
document.write(num.valueof());
</script>
</body>
</html>
Output
Array Object
<!DOCTYPE html>
<html>
<head>
<title>Array Methods in JavaScript</title>
</head>
<body>
<script>
var fruits = ["Apple", "Banana", "Cherry", "Date", "Elderberry"];
document.write("<p>Original Array: " + fruits + "</p>");
fruits.push("Fig");
document.write("<p>After push(): " + fruits + "</p>");
fruits.pop();
document.write("<p>After pop(): " + fruits + "</p>");
fruits.shift();
document.write("<p>After shift(): " + fruits + "</p>");
fruits.unshift("Apricot");
document.write("<p>After unshift(): " + fruits + "</p>");
fruits.sort();
document.write("<p>After sort(): " + fruits + "</p>");
</script>
</body>
</html>
Output
String Object
<!DOCTYPE html>
<html>
<head>
<title>String Object in JavaScript</title>
</head>
<body>
<script>
var str = "Hello, world!";
document.write("<p>Original String: " + str + "</p>");
var upper = str.toUpperCase();
document.write("<p>Uppercase String: " + upper + "</p>");
var lower = str.toLowerCase();
document.write("<p>Lowercase String: " + lower + "</p>");
var length = str.length;
document.write("<p>Length of String: " + length + "</p>");
var substr = str.substring(0, 5);
document.write("<p>Substring of String: " + substr + "</p>");
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<script>
// Math Object
console.log(Math.PI); // 3.141592653589793
console.log(Math.ceil(4.3)); // 5
console.log(Math.floor(4.9)); // 4
// Date Object
console.log(today.getFullYear()); // 2023
// Number Object
let x = 123.456;
console.log(x.toExponential(2)); // 1.23e+2
console.log(x.toFixed(2)); // 123.46
// Array Object
console.log(fruits.length); // 3
fruits.push("date");
// String Object
let greeting = "Hello, world!";
console.log(greeting.length); // 13
</script>
</head>
<body>
</body>
</html>
<?php
// Creating Variables
$name = "John";
$age = 25;
$height = 1.75;
// Creating Constants
define("PI", 3.14159);
<?php
// For Loop
// While Loop
$i = 0;
$i++;
// Do-While Loop
$i = 0;
do {
$i++;
// Foreach Loop
?>
<?php
// Setting a cookie
// Retrieving a cookie
// Deleting a cookie
?>