¡GoConqr estrena diseño! Cuéntanos qué te parece.

Fichas

JavaScript

Willard Givens Computer Studies GRE Inglés 53 fichas

Fichas del conjunto (53)

  1. 1Topic: Data Structures What is destructuring?Breaking down a large data structure (like an array or object) into multiple smaller data structures (like a variable).
    Essentially taking individual elements of a large data structure and distributing them to their own smaller data structures (ex: a variable).
  2. 2Topic: Data Structures Why will this syntax for object destructuring throw an error? (Assume that this is one line of code). How would you fix the error? {a, b} = {a: 1, b: 2};Incorrect because JavaScript will see these curly braces as code blocks, not objects. To fix this issue, wrap the entire line inside of parentheses.
    ({a, b} = {a: 1, b: 2})
  3. 3Topic: Data Structures What would log to the console in the following example? Why? const [x = 10, y = 10, z = 10] = [12, 13]; console.log(z);This would log "10."
    This is an example of array destructuring, but the array we are destructuring has one less piece of information than the variables we are declaring.
    As such, the "z" variable will have a value of 10 since we gave it that as a default value.
  4. 4Topic: Data Structures Given the following array, how might you write a line of code to perform nested destructuring? const array = [1, 2, 3, [4, 5], 6];const [a, b, c, [d, e], f] = array;
  5. 5Topic: Data Structures What would log to the console in the following example? Why? const [a, b, , c] = [1, 2, [3, 4], 5]; console.log(a, b, c);We would log '1,' '2,' and '5' to the console.
    This is an example of array destructuring. In this case, we are using a comma to skip a specific array element we do not wish to extract and assign to a variable.
  6. 6Topic: Object-Oriented Programming Fill in the blank: In object-oriented programming, interactions between objects happen through ______________, which are object methods accessible to things outside of the object the method belongs to.Public Interface (API)
  7. 7Topic: Object-Oriented Programming The Four Principles of Object-Oriented Programming are: 1. 2. 3. 4.1. Abstraction
    2. Encapsulation
    3. Inheritance
    4. Polymorphism
  8. 8Topic: Object-Oriented Programming This Principle of Object-Oriented Programming means ignoring or hiding details in an object that do not matter.Abstraction.
  9. 9Topic: Object-Oriented Programming This Principle of Object-Oriented Programming refers to keeping all properties and methods in an object private except for those you want to be exposed as an API.Encapsulation.
  10. 10Topic: Object-Oriented Programming This Principle of Object-Oriented Programming is when you make all properties of a class available to child classes, forming a hierarchy between them. It allows developers to reuse common logic.Inheritance.
  11. 11Topic: Object-Oriented Programming This Principle of Object-Oriented Programming means that child classes can overwrite methods they inherit from parent classes.Polymorphism.
  12. 12Topic: Object-Oriented Programming Fill in the blank: All objects in JavaScript are linked to a ___________, from which they can inherit properties and methods.Prototype object.
  13. 13Topic: Object-Oriented Programming Fill in the blank: Objects in JavaScript perform ___________ _____________ / _____________, meaning they inherit all properties and methods from their prototype/they delegate functionality to their parent class(es).Prototypal Inheritance / Delegation
  14. 14Topic: Object-Oriented Programming The 3 ways to implement Prototypal Inheritance in JavaScript are by using: 1. 2. 3.1. Constructor Functions
    2. ES6 Classes
    3. Object.create()
  15. 15Topic: Object-Oriented Programming Create a class "Movie" using a constructor function. The class should have properties "Title" and "Genre."const Movie = function(title, genre) {
    this.title = title;
    this.genre = genre;
    }
  16. 16Topic: Object-Oriented Programming 1. Add a property "Runtime" to the Movie class; its value is 120. 2. Add a method "orderTicket." The method does not have to have any parameters or functionality, just show how you would declare it for a constructor function.Movie.prototype.runtime = 120;
    Movie.prototype.orderTicket = function() {};
  17. 17Topic: Object-Oriented Programming True or False: It is best practice to create methods for a constructor inside the constructor itself. This makes the code much cleaner and more performant.False.
    Creating methods inside the constructor will cause the method to be copied onto each instance (not inherited). This will create multiple copies of the same method.
  18. 18Topic: Object-Oriented Programming Instances of constructors have access to properties created within the function constructor itself, as well as properties declared using constructor.prototype. How does the difference in the way these properties are created affect the structure of an instance and the way it accesses the properties?Properties declared inside the constructor function will be copied to each instance; the instances "own" these properties.
    Properties made using constructor.prototype will not be copied to each instance, but they are still accessible through the prototype.
  19. 19Topic: Object-Oriented Programming The ____ ____ is a series of links between between objects. The connections are made through prototypes.Prototype Chain.
  20. 20Topic: Object-Oriented Programming _______._______ is the top of the prototype chain. Its prototype is just "null."Object.prototype.
  21. 21Topic: Object-Oriented Programming Assume you have a class ("Recipe") and one instance of that class ("newRecipe"). Give each level of the prototype chain from, top to bottom (including the instance).1. null
    2. Object.prototype
    3. Recipe.prototype
    4. newRecipe
  22. 22Topic: Object-Oriented Programming 1. What code would you write to create a Recipe class using an expression? 2. What code would you write to create a Recipe class using a declaration? (assume the class currently has nothing inside of it).1. const Recipe = class {}
    2. class Recipe = {}
  23. 23Topic: Object-Oriented Programming The first thing you always do inside a new class is add a ____ _____.Constructor() method.
  24. 24Topic: Object-Oriented Programming True or False: The constructor() method inside a class needs to ALWAYS be called "constructor".True.
  25. 25Topic: Object-Oriented Programming True or False: It is bad practice to create methods directly inside of a class, just like with constructor functions.False.
    It is not bad practice to create methods directly inside a class because these methods are attached to the *prototype* and will not be copied to each instance.
  26. 26Topic: Object-Oriented Programming Which of these statements are incorrect (for the incorrect statements, correct them)? 1. Classes are hoisted. 2. Classes are first-class citizens, meaning they can be passed into functions and returned from functions. 3. Classes are not executed in strict mode, so you need to write "use strict" in each one.1 and 3 are incorrect.
    1. Classes *are* hoisted.
    3. Classes *are* always executed in strict mode.
  27. 27Topic: Object-Oriented Programming Every object in JavaScript can have _____ and _____ properties, which are functions that __ and __ values (as their names imply).Getter and Setter.
    They get and set values.
  28. 28Topic: Object-Oriented Programming Given the following object, 1. Write a getter method that returns the square of the object's integer. 2. Invoke/call the method. const exampleObject = { let integer = 4; }1. get squareOfInteger () {
    return this.integer ** this.integer;
    }
    2. squareOfInteger();
  29. 29Topic: Object-Oriented Programming True or False: Setter functions can have any number of arguments, but it is best practice to only go up to 5.False.
    Setter functions must always have only ONE argument.
  30. 30Topic: Object-Oriented Programming ______ methods are methods only attached to the constructor or class; they *are not* inherited by any of their instances.Static.
  31. 31Topic: Object-Oriented Programming If you have an existing object (exampleObject), what line of code would you write to take a new object (newObject) and set its prototype to exampleObject?const newObject = Object.create(exampleObject);
  32. 32Topic: Object-Oriented Programming True or False: The Object.create() method of creating prototyping inheritance is the least popular way of doing so.True.
  33. 33Topic: Object-Oriented Programming The first thing you need to do after using Object.create() to set an object's prototype is create a method inside the object that does what?Create a method inside the object that sets the object's properties. It does this using the arguments passed into it, and the arguments should match the names of the properties you want to set.
    Example:
    init(property1, property2) {
    this.property1 = property1;
    this.property2 = property2;
    }
  34. 34Topic: Object-Oriented Programming True or False: In traditional Object-Oriented Programming, properties are actually called "fields," and there can be both public and private fields/methods.True.
  35. 35Topic: Object-Oriented Programming True or False: Public Fields in a class are available on all instances of a class, but not the prototype.True.
  36. 36Topic: Object-Oriented Programming Create a public field called "favoriteNumber" and give it a value of 4.favoriteNumber = 4;
    (No "let" or "const" necessary).
  37. 37Topic: Object-Oriented Programming Create a private field named "birthMonth" and give it a value of "June."#birthMonth = June;
  38. 38Topic: Object-Oriented Programming It makes the most sense to only allow/create chaining for methods that ____ _________ ____ __ ________.Set value(s) for a property.
  39. 39Topic: Object-Oriented Programming Given the following class, create a method named "addToPrice" that increases the price by 10. Make the method chainable. class storeItem { cost = 15; }addToPrice() {
    this.cost = this.cost + 10;
    return this;
    }
  40. 40Topic: Fundamentals Every value in JavaScript will either be an _______ or a _______.Object.
    Primitive.
  41. 41Topic: Fundamentals What are the 7 types of primitives in JavaScript? 1. 2. 3. 4. 5. 6. 7.1. Number
    2. String
    3. Boolean
    4. Undefined
    5. Null
    6. Symbol
    7. BigInt
  42. 42Topic: Fundamentals What is the difference between Type Conversion and Type Coercion?Type Conversion: Manually converting one type of value to another.
    Type Coercion: A value type being implicitly converted to another type.
  43. 43What is the difference between "==" and "==="? Which one is better to use?1. Two equal signs is "loose" equality, but three equal signs is "strict" equality.
    2. It is better to use strict equality since it does not perform type coercion.
  44. 44Topic: Fundamentals What is the difference between Falsy and Truthy values?Falsy values are values that are evaluated to "false" in conditional statements (like If statements).
    Truthy values are anything that isn't Falsy.
  45. 45Topic: Fundamentals What are all the Falsy values?1. False (Boolean)
    2. Undefined, Null
    3. " " (Empty String)
    4. NaN (Not a Number)
    5. 0 (Zero)
  46. 46Topic: Fundamentals What is the difference between Statements and Expressions? Give an example of each.Expressions are any piece of code that will produce a final result.
    Example of Expression: 3 + 4;
    Statements are larger pieces of code that are executed but do not produce final values on their own. They aren't allowed inside of template literals.
    Ex: A function block.
  47. 47Topic: Fundamentals Refactor this code using the ternary operator: if (weather < 50) { bringAJacket = true; } else { bringAJacket = false; }bringAJacket = weather < 50 ? true : false;
  48. 48Topic: Fundamentals True or False: Strict Mode isn't necessary for most projects, and to initialize Strict Mode, you just console.log(strict mode).False.
    Strict Mode is useful in every project, and it should be used.
    To initialize Strict Mode, write 'use strict' at the top of your code.
  49. 49Topic: Fundamentals What's the difference between a Function Expression and a Function Declaration?Function Expression is when you assign the function to a variable.
    Ex: const newFunction = function (){}
    Function Declaration is when you just use the function keyword and immediately name it.
    Ex: function newFunction(){}
  50. 50Topic: Fundamentals Which type of function can be invoked/called before they are created in the code: Function Expressions or Function Declarations?Function Declarations.
  51. 51Topic: DOM Manipulation True or False: Keypress events are scoped to each function, so you should attach them to specific elements.False.
    Keypress events are global events, so they should be attached to the document.
  52. 52Topic: DOM Manipulation What are the 3 different types of keyboard events?1. Keydown
    2. Keypress
    3. Keyup
  53. 53Topic: DOM Manipulation To target the specific key involved in a keyboard event, you want to use Event.____.Event.key;

Información

Descripción
Questions about the JavaScript language.
Creado por
Willard Givens
Visitas
1
Valoración

Escríbenos

¿Sobre qué es tu mensaje?

¿Qué te parece el nuevo diseño?

¿Te gusta?