- Funkcja Object.newObject()
- Metoda create-object()
- Funkcja Object.create()
- Konstruktor new Object()
- Inicjator obiektu
(Więcej niż jedna odpowiedź jest poprawna.)
(Więcej niż jedna odpowiedź jest poprawna.)
Podany jest poniższy skrypt:
class Food { constructor(name) { this.name = name; } } class Fruit extends Food{ constructor(name) { super(name); } } let fruit_1 = new Fruit("Banana");
Jaki będzie wynik poniższych wyrażeń?
fruit_1 instanceof Fruit fruit_1 instanceof Food
Wybierz odpowiedź:
fruit_1 instanceof Fruit => false fruit_1 instanceof Food => false
fruit_1 instanceof Fruit => true fruit_1 instanceof Food => true
fruit_1 instanceof Fruit => true fruit_1 instanceof Food => false
let triangle = function(base, height) { return (base * height) / 2; }
function triangle(base, height) { return (base * height) / 2; }
let triangle = (base, height) => { return (base * height) / 2; }