본문 바로가기

블록체인 기반 핀테크 및 응용 SW개발자 양성과정 일기

20210320 Javascript 기초 예습

반응형

<!DOCTYPE html>
<html>
<body>

<h2>The * Operator</h2>

<p id="demo"></p>

<script>
var x = 5;
var y = 2;

var sum = x + y; //7
var sub = x - y; //3
var mul = x * y; //10
var div = x / y; //2.5

var rem = x % y; //1
//var increment = x ++ y; 
//var decrement = x -- y;
var expo = x ** y; // 25 exponentation 거듭제곱
var bin = x ^ y; //7 2진수 xor

var a = x += y; // 7 | same as x = (x + y)
var b = x -= y; // 3 | x = (x - y)
var c = x *= y; // 10  | x = (x * y)
var d = x /= y; // 2.5  | x = (x / y)
var e = x &= y; // 1  } x = (x % y)

document.getElementById("demo").innerHTML = sum;
document.getElementById("demo").innerHTML = sub;
document.getElementById("demo").innerHTML = mul;
document.getElementById("demo").innerHTML = div;
document.getElementById("demo").innerHTML = rem;
document.getElementById("demo").innerHTML = expo;

//Variables 

var length = 16;  //Number

var carName = "Volvo";  //String
//carName = variable
//Volve = vaulue 

var a = 16 + "Volvo";    -> not number and string
= var a = "16" + "Volvo"; -> JavaScript will treat the number as a string

var x = 16 + 4 + "Volvo";
Result : 20Volvo 
var y = "Volvo" + 16 + 4
Result : Volvo164


var x = {
    firstName : "John",      // Object 
    lastName : "Doe"
};




</script>
</body> 
</html> 


JavaScript Comparision Operators 

== equal to 
=== equal value and equal type
!= not equal
!= not equal value or not equal type
> greater than
< less than
>= greater than or equal to
<= less than or equal to 
? ternary operator



JavaScript Comparision Operators 

 

== equal to 

=== equal value and equal type

!= not equal

!= not equal value or not equal type

> greater than

< less than

>= greater than or equal to

<= less than or equal to 

? ternary operator

* JAVA - method

 

  Java script - fuction 

 

  기능임

 

* Loop 반복문 

While 

 

 

=============================================================

 

 

 

 

 

 

 

 

 

 

 

 

 

반응형