- typeof : return the data type
> typeof 1
< "number"
> typeof "1"
< "string"
- .indexOf() : return where is the () index, every index srarts from 0
> 'code'.indexOf('d')
< 2
- === : strict equallity comparison operator which compares the value and the type, faster than ==, strongly recommendable to use === rather than ==
> 1==="1"
< false
> 1=="1"
< true
- true : 1, -1, 'some string'
- false : none 1, ' ', undefined, null
- prompt() : get some value from the user. There is an input window here and it has the ability to receive some information from the user
prompt("your name");
- <br /> : Break line
- document.write() : a command that the test in parentheses to be printed on the web
- for(var = ; boolean; repeat condition)
- continue : it ends only at the moment when if is true
- anonymous function : function which has no name and it is executed immediately. it used when it called one time
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script>
alert('hello world'); //this part is only javascript and all is html content. Because basically javascript running on the browser, therefore html code is basically required.
alert('hello\nworld');//change the line with \n
for(var i=0;i<10;i=i+1){//i=i+1 is same as i++
document.write("hola mundo "+i+"<br />"); //var i=0 means initialization
}
function numbering(){
document.write(1);
}
numbering();//this is a function because there are parentheses, if there are no parentheses, it will be recognized as a variable by javascript
function get_argument(arg){//arg is parameter, receives the value
return arg*1000;//output
}
alert(get_argument(1));//1 is argument, value itself, input
alert(get_argument(2));
(function (){
i=0;
while(i<10){
document.write(i);
i+=1;
}
})();//anonymous function
</script>
</body>
</html>
'JavaScript' 카테고리의 다른 글
ajax, closure (0) | 2021.01.11 |
---|---|
global variable, anonymous function (0) | 2021.01.07 |
global variable, local variable (0) | 2021.01.07 |
.push(), .concat(), .unshift(), .splice, .shift(), .pop(), .reverse() (0) | 2021.01.07 |
UI, API, Regular Expression, .exec, .test, i, g, (), $, \, \s (0) | 2021.01.07 |