Home  • Programming • JavaScript

JavaScript Tutorial - Lesson:3 [Part-B]

JavaScript Data Types:

JavaScript Booleans

Booleans can only have two values: true or false. var x=true; var y=false;
Booleans are often used in conditional testing. You will learn more about conditional testing in a later chapter of this tutorial.

JavaScript Arrays

The following code creates an Array called motorcycles: var motorcycles=new Array(); motorcycles[0]="Hero"; motorcycles[1]="CDI"; motorcycles[2]="Pulser"; condensed array: var motorcycles=new Array("Hero","CDI","Pulser"); literal array: var motorcycles=["Hero","CDI","Pulser"]; Example:
<!DOCTYPE html>
<html>
<body>
<script>
var i;
var motorcycles= new Array();
motorcycles[0] = "Hero";
motorcycles[1] = "CDI";
motorcycles[2] = "Pulser";
for (i=0;i<motorcycles.length;i++)
{
document.write(motorcycles[i] + "<br>");
}
</script>
</body>
</html>

Comments 1


Sad)

Share

About Author
Zinia Islam
Copyright © 2024. Powered by Intellect Software Ltd