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
function httpGet(url) { | |
return new Promise((resolve, reject) => { | |
const request = new XMLHttpRequest(); | |
request.onload = function () { | |
if (this.status === 200) { | |
resolve(this.response); | |
} else { | |
reject(new Error(this.statusText)); | |
} |
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
function printf(format, …params) { | |
console.log('params: ', params); | |
console.log('format: ', format); | |
} | |
printf('%s %d %.2f', 'adrian', 321, Math.PI); // params: [“adrian”, 321, 3.141592653589793] && “format: %s %d %.2f” |
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
function printf(format) { | |
var params = [].slice.call(arguments, 1); | |
console.log('params: ', params); | |
console.log('format: ', format); | |
} | |
printf('%s %d %.2f', 'adrian', 321, Math.PI); // params: [“adrian”, 321, 3.141592653589793] && “format: %s %d %.2f” |
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 logArguments = function() { | |
return arguments; | |
}; | |
logArguments(1, 2, 3, 4, 5) // > [1, 2, 3, 4, 5] |
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
const numbers = ['1', '2', '3', '4']; | |
for(const number of numbers) { | |
console.log(number); | |
} |
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
function example(x = "The x is the x", y = "The y is the y"){ | |
x = x; | |
y = y; | |
console.log(x, y); | |
} | |
example(); // “The x is the x” && “The y is the 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
function example(x, y){ | |
x = x || "The x is the x"; | |
y = y || "The y is the y"; | |
console.log(x, y); | |
} | |
example(); // “The x is the x” && “The y is the 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 SUV = (function () { | |
function SUVConstructor(model){ | |
Car.call(this, model); | |
} | |
SUVConstructor.prototype = Object.create(Car.prototype); | |
SUVConstructor.prototype.constructor = Car; | |
SUVConstructor.prototype.run = function run() { | |
Car.prototype.run.call(this); |
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
class SUV extends Car { | |
run() { | |
super.run(); | |
console.log(`$And {this.model} climbs up to the mountain`); | |
} | |
} | |
const jeep = new SUV(‘Jeep’); | |
jeep.run(); // “Jeep is running more faster than The Flash!” && “And Jeep climbs up to the mountain” |
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
brasilia // > Car {model: “Brasilia”, color: null} | |
// Utilizando o setter | |
brasilia.color = "Amarela" // “Amarela” | |
brasilia // > Car {model: “Brasilia”, color: “Amarela”} | |
// Utiliando o getter | |
brasilia.color // "Amarela" |