Home  • Programming • JavaScript

JavaScript Tutorial - Lesson:3 [Part-A]

JavaScript Data Types:

1.String, 2.Number, 3. Boolean, 4.Array, 5.Object, 6.Null, 7.Undefined.

JavaScript Has Dynamic Types

JavaScript has dynamic types. This means that the same variable can be used as different types: Example var x; // Now x is undefined var x = 5; // Now x is a Number var x = "John"; // Now x is a String

JavaScript Strings

A string is a variable which stores a series of characters like "John Doe". A string can be any text inside quotes. You can use single or double quotes: Example:
<!DOCTYPE html>
<html>
<body>
<script>
var answer1="Welcome to  ";
var answer2="'VCampus' is a learning community.";
document.write(answer1 + "<br>")
document.write(answer2 + "<br>")
</script>
</body>
</html>
Output:

JavaScript Numbers

JavaScript has only one type of numbers. Numbers can be written with, or without decimals: Example:
<!DOCTYPE html>
<html>
<body>
<script>
var x=112.00;
var y=112e5;
var z=112e-5;
document.write(x + "<br>")
document.write(y + "<br>")
document.write(z + "<br>")
</script>
</body>
</html>
Output:

Comments 0


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