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
public class PlasticToyDuck implements ToyDuck { | |
@Override | |
public void squeak() { | |
System.out.println("Squeak squeak"); | |
} | |
} | |
public class ToySparrow implements ToyBird { |
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
public class PlasticToyDuck implements ToyDuck { | |
@Override | |
public void squeak() { | |
System.out.println("Squeak squeak"); | |
} | |
} | |
public class ToySparrow implements ToyBird { |
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 arrayOfBuiltIns = [ | |
Error, | |
Symbol, | |
Promise, | |
RegExp, | |
String, | |
Boolean, | |
Number, | |
Array, | |
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
class Trip { | |
constructor(destination, budget, duration) { | |
this.destination = destination; | |
(this.budget = budget), (this.duration = duration); | |
} | |
durationInHours() { | |
return `${24 * this.duration} hours`; | |
} | |
} |
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
let myTrip = { | |
destination: "Boston" | |
} | |
function findAndAddBudget(obj, argBudget) { | |
return ('budget' in obj) ? obj : {...obj, budget: argBudget} | |
} | |
console.log(myTrip) // { destination: 'Boston' } | |
myTrip = findAndAddBudget(myTrip, 600) | |
console.log(myTrip) // { destination: 'Boston', budget: 600 } |
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 instanceOf(instance, obj) { | |
return instance instanceof obj; | |
} | |
function deleteProperty(instance, property, userObject = null) { | |
if(typeof instance !== 'object') return `Primitive types like ${typeof instance} can not be deleted` | |
let arrayWithUserType = userObject | |
? [userObject, ...arrayOfBuiltIns] | |
: arrayOfBuiltIns; | |
let foundType = arrayWithUserType.find((builtInObj) => |
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 newHello = new String('hello') | |
console.log(typeof newHello) // object | |
console.log(typeof []) // object |
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 hello = 'hello' | |
const one = 1 | |
console.log(hello instanceof String) // false | |
console.log(one instanceof Number) // false | |
console.log(typeof hello) // 'string' | |
console.log(typeof one) // 'number' | |
const newHello = new String('hello') | |
console.log(newHello instanceof Object) // true |
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 arrayOfBuiltIns = [ | |
Error, | |
Promise, | |
RegExp, | |
String, | |
Boolean, | |
Number, | |
Array, | |
Function, | |
Object, |
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
console.log(instance.destination.sort()) // => ['Boston', 'Salem'] | |
console.log(instance.sort()) // TypeError: instance.sort is not a function |
NewerOlder