-
Write our name or something we want to see on compiler we may use this code:
"Musa";
-
If you wanna count your name lenght write down
document.write("musatoktas".lenght);
After write this code you will see 10 number because thatis letter lenght of "musatoktas" word
- You can use * for multiplication and / for division if you want. Enter another valid expression to pass this lesson.
If you wanna see just result on preview screen just write numbers and function which one you want
- For write comment on javascript interreter you should use double slash like;
"//"
- If you wanna open little pop-up on the top of the screen you can use this code. For describe deeply thonk about some adv. sites. When you click on close button a white box pop-up on screen. I am trying to explain create that box.
confirm("something else");
-
For input some datas from user by typing in that box which is I wrote above, you may use this code;
prompt("Are You Sure?");
-Booleans
Booleans means Logical orders such as true, and false. when you write something on interpreter and check its okay or not you can see result by using > or less than (<)
"console.log()"code
Interpret doesn't print out everythink which is you write on it so developers constitudethis code. When you write some thing inside the parentheses it will be print out.
- There are more abreviations to auxiliary your comparisons in Booleans.
List of comparison operators:
"> Greater than
< Less than
<= Less than or equal to
">=" Greater than or equal to
=== Equal to
!== Not equal to
- Combine Them and Use
Just in case we need compare our how much letters in my name we can use that
if ("musatoktas".length >= 7){
console.log("You have a long name!");
}
- Math
Here is some complex math operations
Code:
- ( ): control order of operations
-
- and /: multiplication and division
-
- and +: subtraction and addition
Examples:
- 100/10 evaluates to 10
- "Jane".length + 5 evaluates to 9
- 5*(3+1) evaluates to 20
- Find a Reminder in Division Operations
The modulo symbol is our tool when we trying to find reminder in division operations. there are some examples which is help you to understand;
So if we do 23 % 10, we divide 23 by 10 which equals 2 with 3 left over. So 23 % 10 evaluates to 3.
More examples:
17 % 5 evaluates to 2
13 % 7 evaluates to 6
when you coding these on interpreter you should write like that;
console.log( 19 % 8 );
- Substringing
Substringging means is just show a smaller part of words. Some times we can't see all of the words, because there are no place on display so the code of the browser is make smaller worlds.
Forexample you just wanna see between third letter and seventh letters of "world of the wars" sentence.
"world of the wars".substring(2,7);
- Variables
This is an another fundamental things of JavaScript, and other programming Languages. When you write a code you need to identify a variable which is like name of the system. Actually we using this in our daily life like think about "truck". It has an engine, transmission, tires, and chassis but when we describe it, we just saying "truck". Like this when we mention about big datas we needn't write all of it. we may identify them a variables with a name, and when we write that name computer can understand that big data which is we mention.
For Example my number is "978263176-719297813671", and I need to write my number more than 5 place, so it keeps too long place. Easy way I identify a variable with name myNumber and when Im write this name Computer automatically understand "978263176-719297813671". After you can use your variables with loops.
This is end of first part of java Script Notes