Variables in Javascript-
Javascript variables are containers for storing data values.
A variable is a "named storage" for data.
How To Create Variables-
1-let
example-1
Example-2
const
in this variable, if you are assigning a value that value cant change . if you want to change it will give you a compile-time error
var
global or functional scope .
var can tolerate redeclaration
Variable Naming rule in javascript
1-alphabet but cant start with digit
2-name must conatin letter ,digit and _or symbols
3-keywords cant be used for variable name
4-casesensitive
Lets go to download live server in visual studio .first open visual studio and left side there is one option extension click on it and search live server ,and install first one.
second you have to download runner same as previous step serch runner and here also click on first one .
see in this two there is some difference first one live server is for work on web and second one is for work in console .like if you want to run program on console than you can use runner or else if you want to run on web than you have to use live server .
Standard message Console
First one is window alert
<script>
//this is called interrnal javascript
//your javascript ocode goes here
//console.log("here whats going on");
let message="hey iam rocking";
window.alert(message);
</script>
promt
<script>
//prompt in javascript example
let message="hey iam rocking";
prompt(message);
</script>
confirm
<script>
//confirm in javascript example
let option= confirm("do you want to jojn");
alert(option);
</script>
<script>
//confirm in javascript example
let option= confirm("do you want to jojn");
if(option==true){
location.href="http://odiamusic.in"
}
</script>
Now we will discuss about console object ,where there are so many functions are availabel which is log,warn,error,table,time,cons,clear.these functions are work only on console not in web .
<script>
//console functions
//see in console there are lot of option availabel like information,warning
//log general use for debugging
console.log("hey you know abou console in javascript");
//warn is use for if you want to warning something
console.warn("this is warning message");
//error is like if you want to showing some error in console that time we are using
console.error("hey this is error");
//info option also availabel in console
console.info("this is information purpose");
//setTimeout is for after that time it willl clear
setTimeout(function(){
console.log("clearing");
console.clear();
},3000);
//clear is a function which is used for clear all function in console
console.clear();
</script>
HOW TO CHECK TYPE OF VARIABLE IN JAVASCRIPT
0 Comments