:ﺪﻨﺷﺎﺑ ﺮﯾﺩﺎﻘﻣ ﯼﻭﺎﺣ ﺪﻨﻧﺍﻮﺗ ﯽﻣ ﻪﮐ ﺩﺭﺍﺩ ﺩﻮﺟﻭ ﻒﻠﺘﺨﻣ ﻩﺩﺍﺩ ﻉﻮﻧ 5 ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﺭﺩ
ﻪﺘﺷﺭ
ﻩﺭﺎﻤﺷ
ﯽﻟﻮﺑ
ءﯽﺷ
ﺩﺮﮑﻠﻤﻋ
:ﺩﺭﺍﺩ ﺩﻮﺟﻭ ﯽﺷ ﻉﻮﻧ 6
ءﯽﺷ
ﺦﯾﺭﺎﺗ
ﻪﯾﺍﺭﺁ
ﻪﺘﺷﺭ
ﻩﺭﺎﻤﺷ
ﯽﻟﻮﺑ
:ﺪﻨﺷﺎﺑ ﺮﯾﺩﺎﻘﻣ ﯼﻭﺎﺣ ﺪﻨﻧﺍﻮﺗ ﯽﻤﻧ ﻪﮐ ﻩﺩﺍﺩ ﻉﻮﻧ 2 ﻭ
null
ﻩﺪﺸﻧ ﻒﯾﺮﻌﺗ
.ﺪﯿﻨﮐ ﻩﺩﺎﻔﺘﺳﺍ ﻩﺩﺍﺩ ﻉﻮﻧ ﻥﺩﺮﮐ ﺍﺪﯿﭘ ﯼﺍﺮﺑ typeof
ﺮﮕﻠﻤﻋ ﺯ
typeof "John"
// Returns "string"
typeof 3.14
// Returns "number"
typeof NaN
// Returns "number"
typeof false
// Returns "boolean"
typeof [1,2,3,4] // Returns
"object"
typeof {name:'John', age:34}
// Returns "object"
typeof new Date()
// Returns "object"
typeof function () {} // Returns
"function"
typeof myCar
// Returns "undefined" *
typeof null
// Returns "object"
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Operators</h1>
<h2>The typeof Operator</h2>
<p>The typeof operator returns the type of a variable, object, function or expression:</p>
<p id="demo"></p>
<script>
document.getElementById("demo").innerHTML =
"'John' is " + typeof "John" + "<br>" +
"3.14 is " + typeof 3.14 + "<br>" +
"NaN is " + typeof NaN + "<br>" +
"false is " + typeof false + "<br>" +
"[1, 2, 3, 4] is " + typeof [1, 2, 3, 4] + "<br>" +
"{name:'John', age:34} is " + typeof {name:'John', age:34} + "<br>" +
"new Date() is " + typeof new Date() + "<br>" +
"function () {} is " + typeof function () {} + "<br>" +
"myCar is " + typeof myCar + "<br>" +
"null is " + typeof null;
</script>
</body>
</html>
:ﺪﯿﻨﮐ ﻪﺟﻮﺗ ﺎﻔﻄﻟ
ﺖﺳﺍ ﺩﺪﻋ NaN ﻩﺩﺍﺩ ﻉﻮﻧ
ﺖﺳﺍ ﯽﺷ ﻪﯾﺍﺭﺁ ﮏﯾ ﻩﺩﺍﺩ ﻉﻮﻧ
ﺖﺳﺍ ﯽﺷ ﺦﯾﺭﺎﺗ ﮏﯾ ﻩﺩﺍﺩ ﻉﻮﻧ
ﺖﺳﺍ ﯽﺷ null ﻩﺩﺍﺩ ﻉﻮﻧ
ﺖﺳﺍ ﻩﺪﺸﻧ ﻒﯾﺮﻌﺗ ﻩﺪﺸﻧ ﻒﯾﺮﻌﺗ ﺮﯿﻐﺘﻣ ﮏﯾ ﻩﺩﺍﺩ ﻉﻮﻧ
ﺖﺳﺍ ﻩﺪﺸﻧ ﻩﺩﺍﺩ ﺹﺎﺼﺘﺧﺍ ﻥﺁ ﻪﺑ ﯼﺭﺍﺪﻘﻣ ﻪﮐ ﯼﺮﯿﻐﺘﻣ ﻩﺩﺍﺩ ﻉﻮﻧ
.ﺪﯿﻨﮐ ﻩﺩﺎﻔﺘﺳﺍ ﺖﺳﺍ (ﺦﯾﺭﺎﺗ ﮏﯾ ﺎﯾ) ﻪﯾﺍﺭﺁ ﮏﯾ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﯽﺷ ﮏﯾ ﺎﯾﺁ ﻪﮑﻨﯾﺍ ﻦﯿﯿﻌﺗ ﯼﺍﺮﺑ
ﺖﺳﺍ ﯽﻓﺎﺿﺍ ﭻﯿﻫ ﻥﻭﺪﺑ ﻭ ﻩﺩﺎﺳ ﻩﺩﺍﺩ ﺭﺍﺪﻘﻣ ﮏﯾ ﻪﯿﻟﻭﺍ ﻩﺩﺍﺩ ﺭﺍﺪﻘﻣ ﮏﯾ
:ﺪﻧﺍﺩﺮﮔﺮﺑ ﺍﺭ ﻪﯿﻟﻭﺍ ﻉﺍﻮﻧﺍ ﻦﯾﺍ ﺯﺍ ﯽﮑﯾ ﺪﻧﺍﻮﺗﯽﻣ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ :ﺪﻧﺍﺩﺮﮔﺮﺑ ﺍﺭ ﻩﺪﯿﭽﯿﭘ ﻉﻮﻧ ﻭﺩ ﺯﺍ ﯽﮑﯾ ﺪﻧﺍﻮﺗ ﯽﻣ .ﺪﻧﺍﺩﺮﮔﯽﻣﺮﺑ null ﻭ ﺎﻫﻪﯾﺍﺭﺁ ،ﺎﯿﺷﺍ ﯼﺍﺮﺑ ﺍﺭ "code class="w3-codespan">typeof .ﺪﻧﺍﺩﺮﮔﯽﻣﺮﺑ ﻊﺑﺍﻮﺗ ﯼﺍﺮﺑ ﺍﺭ "ﯽﺷ" → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ .ﺪﻨﺘﺴﻫ ﺎﯿﺷﺍ ﺎﻫ ﻪﯾﺍﺭﺁ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﺭﺩ ﺍﺮﯾﺯ ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ ﺎﻫ ﻪﯾﺍﺭﺁ ﯼﺍﺮﺑ ﺍﺭ " / * - + ) ﺎﻫﺭﻮﺗﺍﺮﭘﺍ .ﺖﺳﺍ ﺭﻮﺗﺍﺮﭘﺍ .ﺖﺴﯿﻧ ﺮﯿﻐﺘﻣ ﮏﯾ ﻞﻣﺎﺷ) ﻪﺘﺷﺭ ﮏﯾ ﻪﺸﯿﻤﻫ ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ ﺍﺭ ﻩﺪﻧﺯﺎﺳ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ .ﺮﯿﺧ ﺎﯾ ﺖﺳﺍ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ :ﺮﯿﺧ ﺎﯾ ﺖﺳﺍ ﻪﯾﺍﺭﺁ ﻊﺑﺎﺗ ﮏﯾ ﯽﺷ ﺎﯾﺁ ﻪﮐ ﺪﯿﻨﮐ ﯽﺳﺭﺮﺑ ﺪﯿﻧﺍﻮﺗ ﯽﻣ ،ﺮﺗ ﻩﺩﺎﺳ ﯽﺘ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ ﺮﯿﺧ ﺎﯾ ﺖﺳﺍ a ﯽﺷ ﮏﯾ ﺎﯾﺁ ﻪﮐ ﺪﯾﻮﺷ ﻪﺟﻮﺘﻣ ﺎﺗ ﺪﯿﻨﮐ ﯽﺳﺭﺮﺑ ﺍﺭ ﻩﺪﻧﺯﺎﺳ ﯽﮔﮋﯾﻭ ﺪﯿﻧﺍﻮﺗ ﯽﻣ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ :ﺖﺳﺍ ﺦﯾﺭﺎﺗ ﺩﺮﮑﻠﻤﻋ ﮏﯾ ﯽﺷ ﺎﯾﺁ ﻪﮐ ﺪﯿﻨﮐ ﯽﺳﺭﺮﺑ ﺪﯿﻧﺍﻮﺗ ﯽﻣ ،ﺮﺗ ﻩﺩﺎﺳ ﯽﺘﺣ ﺎﯾ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ .ﺖﺳﺍ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ .ﺩﺮﮐ ﯽﻟﺎﺧ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ .ﺩﺭﺍﺪﻧ .ﺩﺭﺍﺩ ﻉﻮﻧ ﻢﻫ ﻭ ﯽﻧﻮﻧﺎﻗ ﺵﺯﺭﺍ ﻢﻫ ﯽﻟﺎﺧ ﻪﺘﺷﺭ ﮏﯾ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ .ﺩﺭﺍﺪﻧ ﺩﻮﺟﻭ ﻪﮐ ﺪﺷﺎﺑ ﯼﺰﯿﭼ ﺖﺳﺍ ﺭﺍﺮﻗ .ﺖﺳﺍ "ﺰﯿﭼ ﭻﯿﻫ" .ﺖﺳﺍ ﯽﺷ ﮏﯾ .ﺪﺷﺎﺑ :ﺪﯿﻨﮐ ﯽﻟﺎﺧ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ :ﺪﯿﻨﮐ ﯽﻟﺎﺧ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ :ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ ﺍﺭ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ ﺪﻧﺍﺩﺮﮔ ﯽﻣﺮﺑ ﻭ ﺪﻨﮐ ﯽﻣ ﯽﺑﺎﯾﺯﺭﺍ ﺍﺭ ﺕﺭﺎﺒﻋ ﮏﯾ void ﺮﮕﻠﻤﻋ → ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧtypeof
ﻪﺘﺷﺭ
ﻩﺭﺎﻤﺷ
ﯽﻟﻮﺑ
ﻩﺪﺸﻧ ﻒﯾﺮﻌﺗ
ﻝﺎﺜﻣ
typeof "John" // Returns
"string"
typeof 3.14 // Returns
"number"
typeof true // Returns
"boolean"
typeof false // Returns
"boolean"
typeof x
// Returns "undefined" (if x has no value)
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Operators</h1>
<h2>The typeof Operator</h2>
<p>The typeof operator returns the type of a variable or an expression.</p>
<p id="demo"></p>
<script>
document.getElementById("demo").innerHTML =
typeof "john" + "<br>" +
typeof 3.14 + "<br>" +
typeof true + "<br>" +
typeof false + "<br>" +
typeof x;
</script>
</body>
</html>
ﻩﺪﯿﭽﯿﭘ ﯼﺎﻫ ﻩﺩﺍﺩ
typeof
ﺮﮕﺩﺮﮑﻠﻤﻋ
ءﯽﺷ
ﻉﻮﻧ<"code class="w3-codespan> ﺮﮕﻠﻤﻋ
ﻝﺎﺜﻣ
typeof {name:'John', age:34} // Returns "object"
typeof [1,2,3,4]
// Returns "object" (not "array", see note below)
typeof null // Returns
"object"
typeof function myFunc(){} // Returns "function"
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Operators</h1>
<h2>The typeof Operator</h2>
<p>The typeof operator returns object for both objects, arrays, and null.</p>
<p>The typeof operator does not return object for functions.</p>
<p id="demo"></p>
<script>
document.getElementById("demo").innerHTML =
typeof {name:'john', age:34} + "<br>" +
typeof [1,2,3,4] + "<br>" +
typeof null + "<br>" +
typeof function myFunc(){};
</script>
</body>
</html>
ﯽﺷ<"co
ﻉﻮﻧ ﻩﺩﺍﺩ ﻉﻮﻧ
ﻉﻮﻧ<"code class="w3-codespan>
typeof
ﺮﮕﻠﻤﻋ ،ﺎ ﻩﺪﻧﺯﺎﺳ ﺖﯿﮑﻟﺎﻣ
constructor
ﯽﮔﮋﯾﻭ ﻝﺎﺜﻣ
"John".constructor
// Returns function String() {[native code]}
(3.14).constructor
// Returns function Number() {[native code]}
false.constructor // Returns
function Boolean() {[native code]}
[1,2,3,4].constructor
// Returns function Array() {[native code]}
{name:'John',age:34}.constructor
// Returns function Object() {[native code]}
new Date().constructor
// Returns function Date() {[native code]}
function () {}.constructor // Returns
function Function(){[native code]}
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Properties</h1>
<h2>The constructor Property</h2>
<p>The constructor property returns the constructor function for a variable or an
object.</p>
<p id="demo"></p>
<script>
document.getElementById("demo").innerHTML =
"john".constructor + "<br>" +
(3.14).constructor + "<br>" +
false.constructor + "<br>" +
[1,2,3,4].constructor + "<br>" +
{name:'john', age:34}.constructor + "<br>" +
new Date().constructor + "<br>" +
function () {}.constructor;
</script>
</body>
</html>
ﻪﯾﺍﺭﺁ<"code class="w3-codespan> ﮏﯾ ﯽﺷ ﮏﯾ ﺎﯾﺁ ﺪﯿﻤﻬﻔﺑ ﺎﺗ ﺪﯿﻨﮐ ﯽﺳﺭﺮﺑ
ﻝﺎﺜﻣ
function isArray(myArray) {
return myArray.constructor.toString().indexOf("Array") > -1;
}
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Arrays</h1>
<p>This "home made" isArray() function returns true when used on an array:</p>
<p id="demo"></p>
<script>
const fruits = ["Banana", "Orange", "Apple"];
document.getElementById("demo").innerHTML = isArray(fruits);
function isArray(myArray) {
return myArray.constructor.toString().indexOf("Array") > -1;
}
</script>
</body>
</html>
ﻝﺎﺜﻣ
function isArray(myArray) {
return myArray.constructor
=== Array;
}
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Array Object</h1>
<p>This "home made" isArray() function returns true when used on an array:</p>
<p id="demo"></p>
<script>
const fruits = ["Banana", "Orange", "Apple", "Mango"];
document.getElementById("demo").innerHTML = isArray(fruits);
function isArray(myArray) {
return myArray.constructor === Array;
}
</script>
</body>
</html>
ﻝﺎﺜﻣ
function isDate(myDate) {
return myDate.constructor.toString().indexOf("Date") > -1;
}
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Date Object</h2>
<p>This "home made" isDate() function returns true when used on an date:</p>
<p id="demo"></p>
<script>
const myDate = new Date();
document.getElementById("demo").innerHTML = isDate(myDate);
function isDate(myDate) {
return myDate.constructor.toString().indexOf("Date") > -1;
}
</script>
</body>
</html>
ﻝﺎﺜﻣ
function isDate(myDate) {
return myDate.constructor === Date;
}
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Date Object</h2>
<p>This "home made" isDate() function returns true when used on an date:</p>
<p id="demo"></p>
<script>
const myDate = new Date();
document.getElementById("demo").innerHTML = isDate(myDate);
function isDate(myDate) {
return myDate.constructor === Date;
}
</script>
</body>
</html>
ﻩﺪﺸﻧ ﻒﯾﺮﻌﺗ
undefined
ﺭﺍﺪﻘﻣ ﯼﺍﺭﺍﺩ ،ﺭﺍﺪﻘﻣ ﻥﻭﺪﺑ ﺮﯿﻐﺘﻣ ﮏﯾ ،ﺖﭙﯾ ﻝﺎﺜﻣ
let car; // Value is undefined,
type is undefined
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Operators</h1>
<h2>The typeof Operator</h2>
<p>The value (and the data type) of a variable with no value is <b>undefined</b>.</p>
<p id="demo"></p>
<script>
let car;
document.getElementById("demo").innerHTML =
car + "<br>" + typeof car;
</script>
</body>
</html>
undefined
ﺭﺍﺪﻘﻣ ﻢﯿﻈﻨﺗ ﺎﺑ ﻥﺍﻮﺗ ﯽﻣ ﺍﺭ ﯼﺮﯿﻐﺘﻣ ﻝﺎﺜﻣ
car = undefined; // Value is undefined,
type is undefined
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Operators</h1>
<h2>The typeof Operator</h2>
<p>Variables can be emptied if you set the value to <b>undefined</b>.</p>
<p id="demo"></p>
<script>
let car = "Volvo";
car = undefined;
document.getElementById("demo").innerHTML = car + "<br>" + typeof car;
</script>
</body>
</html>
ﯽﻟﺎﺧ ﯼﺎﻫ ﺵﺯﺭﺍ
undefined
ﻪﺑ ﯽﻄﺑﺭ ﯽﻟﺎﺧ ﺭﺍﺪﻘﻣ ﮏﯾ ﻝﺎﺜﻣ
let car = ""; //
The value is
"", the typeof is "string"
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript</h2>
<p>An empty string has both a legal value and a type:</p>
<p id="demo"></p>
<script>
let car = "";
document.getElementById("demo").innerHTML =
"The value is: " +
car + "<br>" +
"The type is: " + typeof car;
</script>
</body>
</html>
ﯽﻟﺎﺧ
null
null
ﻩﺩﺍﺩ ﻉﻮﻧ ،ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﺭﺩ ،ﻪﻧﺎﻔﺳﺄﺘﻣnull
ﺪﯾﺎﺑ .ﺖﺳﺍ ﯽﺷ ﮏﯾ null
ﯼﻭﺭ ﺮﺑ ﻥﺁ ﻢﯿﻈﻨﺗ ﺎﺑ ﺍﺭ ﯽﺷ ﮏﯾ ﺪﯿﻧﺍﻮﺗ ﯽ ﻝﺎﺜﻣ
let person = {firstName:"John", lastName:"Doe", age:50, eyeColor:"blue"};
person = null; //
Now value is null,
but type is still an object
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript</h2>
<p>Objects can be emptied by setting the value to <b>null</b>.</p>
<p id="demo"></p>
<script>
let person = {firstName:"John", lastName:"Doe", age:50, eyeColor:"blue"};
person = null;
document.getElementById("demo").innerHTML = typeof person;
</script>
</body>
</html>
undefined
ﯼﻭﺭ ﺮﺑ ﻥﺁ ﻢﯿﻈﻨﺗ ﺎﺑ ﺍﺭ ﯽﺷ ﮏﯾ ﺪﯿﻧ ﻝﺎﺜﻣ
let person = {firstName:"John", lastName:"Doe", age:50, eyeColor:"blue"};
person = undefined; //
Now both value and type is undefined
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Objects</h1>
<h2>The undefined Data Type</h2>
<p>Objects can be emptied by setting the value to <b>undefined</b>.</p>
<p id="demo"></p>
<script>
let person = {firstName:"John", lastName:"Doe", age:50, eyeColor:"blue"};
person = undefined;
document.getElementById("demo").innerHTML = person;
</script>
</body>
</html>
Null ﻭ Undefined ﻦﯿﺑ ﺕﻭﺎﻔﺗ
ﻩﺪﺸﻧ ﻒﯾﺮﻌﺗ
ﻭ null
ﺪtypeof undefined
// undefined
typeof null
// object
null === undefined
// false
null == undefined
// true
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Operators</h1>
<h2>The typeof Operator</h2>
<p>Undefined and null are equal in value but different in type:</p>
<p id="demo"></p>
<script>
document.getElementById("demo").innerHTML =
typeof undefined + "<br>" +
typeof null + "<br><br>" +
(null === undefined) + "<br>" +
(null == undefined);
</script>
</body>
</html>
ﺭﻮﺗﺍﺮﭘﺍ ﻪﻧﻮﻤﻧ
true
،ﺪﺷﺎﺑ ﻩﺪﺷ ﺺﺨﺸﻣ ﯽﺷ ﺯﺍ ﯼﺍ ﻪﻧﻮﻤﻧ ﯽ ﻝﺎﺜﻣ
const cars = ["Saab", "Volvo", "BMW"];
(cars instanceof Array);
(cars instanceof Object);
(cars instanceof String);
(cars instanceof Number);
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Operators</h1>
<h2>The instanceof Operator</h2>
<p>The instanceof operator returns true if an object is an instance of a specified object:</p>
<p id="demo"></p>
<script>
const cars = ["Saab", "Volvo", "BMW"];
document.getElementById("demo").innerHTML =
(cars instanceof Array) + "<br>" +
(cars instanceof Object) + "<br>" +
(cars instanceof String) + "<br>" +
(cars instanceof Number);
</script>
</body>
</html>
void ﺭﻮﺗﺍﺮﭘﺍ
ﻝﺎﺜﻣ
<a href="javascript:void(0);">
Useless link
</a>
<a href="javascript:void(document.body.style.backgroundColor='red');">
Click me to change the background color of body to red
</a>
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Operators</h1>
<h2>The void Operator</h2>
<p>
<a href="javascript:void(0);">Useless link</a>
</p>
<p>
<a href="javascript:void(document.body.style.backgroundColor='red');">
Click me to change the background color of body to red.</a>
</p>
</body>
</html>