- numbers
- strings
- objects
- boolean
document.getElementById("demo").innerHTML =
typeof true + "<br>" +
typeof false;
</script>
- null
var person = {firstName:"John", lastName:"Doe", age:50, eyeColor:"blue"};
var person = null;
document.getElementById("demo").innerHTML = typeof person;
</script>
out put object
- undefined
var person;
document.getElementById("demo").innerHTML =
person + "<br>" + typeof person;
</script>
💥JavaScript evaluates expressions from left to right. Different sequences can produce different results
👊<script>
var x = "Volvo" + 16 + 4;
document.getElementById("demo").innerHTML = x;
</script>
output volvo164
👊 <script>
var x = 16 + 4 + "Volvo";
document.getElementById("demo").innerHTML = x;
</script>
output 20Volvo
💥We can use single or double invert comma for string & use quotes inside a string
👊<script>
var carName1 = "Volvo XC60";
var carName2 = 'Volvo XC60';
var answer1 = "It's alright";
var answer2 = "He is called 'Johnny'";
var answer3 = 'He is called "Johnny"';
document.getElementById("demo").innerHTML =
carName1 + "<br>" +
carName2 + "<br>" +
answer1 + "<br>" +
answer2 + "<br>" +
answer3;
</script>
output
Volvo XC60
Volvo XC60
It's alright
He is called 'Johnny'
He is called "Johnny"
No comments:
Post a Comment