JavaScript buttonの練習
algebra ˈældʒəbrə 代数学
In javascript, the first character must be a letter, or a underscore(_), or a dollersign($). Like in HTML and CSS, class and ID name of the first character. And ofsource, case sensitive.
var lastname, lastName; lastname = "Doe" lastName ="John" two differrent variables.
button can change the headline
also change paragraph
HTML JavaScript, HTML Button, HTML DOM Button Object
var x=50; var y=100; var z=x + y;
z is...
id=""は一回のみ適用、class=""は複数 getElementByClassName()は、getElementById()よりちょっと難しい?
getElementById() idが複数あってしまったら最初の方に適用される。そもそもidは一回用だから複数あってはダメなのだが。
try it にidを2つ付けた場合。index=0優先。
HTML DOM getElementByClassName() MethodText
car and cost.
ternary 3つのユニット、要素を持つもの、3進法、3元の、3値
expoential notation "123e5 = 12300000" "123e-5 = 0.00123"
var cars = ["Saab", "Volvo", "BMW""] array index numbers are [0, 1, 2]
Object
variables= {name:"values", name:"values", name:"values",};
var pesron2 = {firstname2:"Ted", lastname2:"Mosby", age2:"50", eycolor2:"blue"};
An empty string has both a legal value and a type. If 'var car= "" '
The value is:(empty/nothing/null)
The type is : string;
JavaScript arithmetic, == equal, === strict equal, != Unequal, !== Strict unequal, ++ icrement, -- decrement, % Modulus(remainder),
JavaScript Assignment
Operator | Example | Same as |
---|---|---|
= | x = y | x = y |
+= | x+=y | x = x + y |
-= | x -= y | x= x - y |
*= | x *= y | x = x*y |
/= | x /= y | x = x/y |
%= | x %= y | x = x % y |
<<= | x <<= y | x = x << y |
>>= | x >>= y | x = x >l;> y |
&= | x &= y | x = x & y |
^= | x ^= y | x = x ^ y |
|= | x |= y | x = x | y |
**= | x **= y | x = x ** y |
Difference between undefined and null undefined and null are equal in value, but different in type: typeof undefined //undefined typeof null //object null === undefined //false null == undefined //true
\'= ' , \"= " ,\\ = \
.replace()
Replace /g is replace all values, HD10 and ipad are android OS.
common mistakes var x = 10; //number var y = 20; //number var z = "The answer is: " + x + y; //string //=== "The result is: 1020 var x = 10 //number var y = 20 //number var z = "30"; //string var result = x + y + z; //==== "3030" Javascript Numbers typeof NaN; // returns "number"
Javascript Type conversationsl, typeof
arrray .length of last index number
declareing: var fruits = ["Banana", "Orange", "Apple", "Mango"]
local, grobal variables
declareing variables inside Javascript function, code can only use the function.
var "variables name"= "something variables"; grobal function myFunction() { var carName("variables name") = "Volvo"; this is local variables: code here CAN use carName } //code here can NOT access the carName(local variables)
Array.forEach() calls a function for each array element. That is good, I think.
コメント
コメントを投稿