This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and Deploy | |
| on: | |
| push: | |
| branches: | |
| - master | |
| jobs: | |
| build: | |
| name: Build | |
| runs-on: ubuntu-latest |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <title>JS Bin</title> | |
| </head> | |
| <body> | |
| <script id="jsbin-javascript"> | |
| var add = function(x, y) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var addFive = function(num){ | |
| if (this.hoge === undefined) { | |
| this.hoge = 1; | |
| } | |
| return num + 5 + this.hoge; | |
| }; | |
| console.log(addFive(4)); //10 | |
| console.log(addFive.apply(null, [4])); //10 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var a = b = 0; | |
| for (i = 0; i < 100; i++) { | |
| if (Math.round( Math.random()) > 0) { | |
| a++; | |
| } else { | |
| b++; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| CREATE [UNIQUE|FULLTEXT|SPATIAL] INDEX index_name | |
| [index_type] | |
| ON tbl_name (index_col_name,...) | |
| [index_option] | |
| [algorithm_option | lock_option] ... | |
| //CREATE INDEX idx_foo_column ON tbl_bar (foo_column DESC) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //before | |
| for (var i = 0, max = myarray.length; i < max; i + +) { | |
| // do something with myarray[ i] | |
| } | |
| //after | |
| var i, myarray = []; | |
| for (i = myarray.length; i--) { | |
| // do somthing with myarray[i] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var parseQueryString = function(queryString) { | |
| var params = {}, | |
| queries, temp, i, l; | |
| queries = queryString.split('&'); | |
| l = queries.length; | |
| for (i = 0; i < l; i++) { | |
| temp = queries[i].split('='); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //javascript php foreach equivalent | |
| var obj = {prop1: 5, prop2: 13, prop3: 8}; | |
| for (var item in obj) { | |
| console.log(item + ':' + obj[item]); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var arr = new Array(2, 3, 4); | |
| console.log(arr); // [2, 3, 4] | |
| var arr2 = new Array(2); | |
| console.log(arr2); // [undefined, undefined] ew... | |
| console.log(arr2.length); //2 | |
| // using array literal | |
| var a = [3.14]; | |
| console.log( a[ 0]); // 3.14 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //antipattern | |
| var arr = new Array("apple", "google", "yahoo"); | |
| //the exact same array | |
| var arr = ["apple", "google", "yahoo"]; | |
| console.log(typeof arr); // "object" | |
| console.log(arr.constructor === Array); // true |
NewerOlder