An example that shows the difference between creating a JavaScript class and subclass in ES5 and ES6.
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
'use strict'; | |
/** | |
* Reverses a string or array. | |
* | |
* @param {(String|Array)} i - The string or array. | |
* @return {(String|Array)} | |
*/ | |
function reverse(i) { | |
var isString = false; |
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
'use strict'; | |
/** | |
* Sorts an array using the insertion algorithm. | |
* | |
* @param {Array} array - The array to be sorted. | |
* @return {Array} | |
*/ | |
function insertionSort(array) { | |
if (array.constructor !== Array) { |
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
'use strict'; | |
/** | |
* Fullscreen (CTRL + F) | |
*/ | |
slate.bind('f:ctrl', function(window) { | |
window.doOperation(move({ | |
x: 'screenOriginX', | |
y: 'screenOriginY', | |
width: 'screenSizeX', |
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 webdriver = require('selenium-webdriver'); | |
// since no browser is specified in the builder | |
// you can set the target browser at runtime | |
// through the SELENIUM_BROWSER environment variable | |
// e.g., SELENIUM_BROWSER=phantomjs node driver_test.js | |
var driver = new webdriver.Builder().build(); | |
driver.get('https://www.google.com'); | |
driver.getTitle().then(function(title) { | |
console.log(title); | |
}); |
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
'use strict'; | |
/** | |
* Module dependencies. | |
*/ | |
var webdriver = require('selenium-webdriver'); | |
var chrome = require('selenium-webdriver/chrome'); | |
/** | |
* Chrome options. |
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 webdriver = require('selenium-webdriver'); | |
var By = webdriver.By; | |
var driver = new webdriver.Builder().forBrowser('safari').build(); | |
driver | |
.get('https://www.wikipedia.org') | |
.then(function() { | |
return driver.sleep(1000); | |
}) | |
.then(function() { |
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
{ | |
"parser": "babel-eslint", | |
"env": { | |
"browser": true, // allow browser globals like `window` and `document` | |
"node": true, // allow node globals like `process` | |
"commonjs": true, // allow globals like `require` and `exports` | |
"mocha": true // allow mocha globals like `describe` and `it` | |
}, |
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
'use strict'; | |
/** | |
* Convert arguments from array-like object to array. | |
* | |
* @param {...*} | |
* @return {Array} | |
*/ | |
function argumentsToArray() { | |
return Array.prototype.slice.call(arguments, 0); |
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
'use strict'; | |
/** | |
* Curry the function. | |
* | |
* @param {Function} func - The function to curry. | |
* @param {...*} | |
* @return {Function} | |
*/ | |
function curry(func) { |
OlderNewer