投稿

12月, 2019の投稿を表示しています

JavaScriptとgrid

イメージ
JavaScript Class Javascript Class Method JavaScript Classes A class is a type of function, use the keyword of class. When the class to be created, always need a constructor() method. ↑ onload="showResize()" を加えてresize していなくてもwindow size が表示されるように。reloadだと消える。 Jump screen end class Car { constructor(name) { this.carname = name; // this を使わないとobjectを呼び出せない(?から?) } present(y) { return y + ", We have a " + this.carname; } } thecar = new Car("Saab"); document.getElementById("CMethod").innerHTML = thecar.present("Yes"); time now Date reference JavaScript Class Inheritance Use the "extends" keyword to inherit all methods from another class. Use the "super" method to call the parent's constructor function. //extends and super() class Car1 { constructor(brand) { this.carname1 = brand; } presntt1() { return 'We have a ' + this.carname1; } } cl

Loopの練習

Loop Loop The for/in statement loops through the properties of an object. appear Looping over an Array appearing visibility: visible | hidden | collapse | initial | inherit ; で<button>を枠を残したまま隠す var movies = ["fight Club", "Panic Room", "Zodiac", "Social Network", "Gone Girl"]; var i1; var text2 =""; ""; で空っぽのstringを作らないと最初がundefined になってしまう for (i1 =0; i1 < movies.length; i1++) { // .length methodを使えばarrayのindex を数えなくてもいい document.getElementById("davidfincherM").innerHTML = text2 += movies[i1] + " "; } for/of がうまく行かない for/of のtry it が。 document.write() とfor(index of variables); でなんとか… document.getElementById().innerHTML で書くとarrayの最後だけになってしまう。 document.write() はhtmlの最後に書き加えられる? for and while for syntax for (statement1; statement2; statement3){ // code block to be excuted } var i3 =0; var text3 =""; for (;

Arrayの練習

イメージ
Array 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) arrray .length of last index number declareing: var fruits = ["Banana", "Orange", "Apple", "Mango"] fruits.length-2 Make fruits list. Array.forEach() calls a function for each array element. That is good, I think. .forEach() <button> に.forEach() のmethodを与えようとするが失敗。function でfunction makelist2(value) をcallしたかった。 Adding Adding elements with high index can create undefined "holes" in an array. fruits[6] document.getElementById("").innerHTML = points[0]; var points = new.arrary(40); //typ