Computed Property
  • Computed Property

    Computed properties are reactive, performant and tracks dependencies while performing complex logical calculations in your Vue applications.

    Test your knowledge on Computed property feature of Vue 3.

    9 Questions
  • Computed property

    Computed property helps you extract complex logic away from the component template while still maintaining reactivity.

    Computed properties are only run when its reactive dependencies have changed.

    Syntax:

    <script setup> 
     const completedList = computed(() => 
     {
      return items.value.filter( 
       item => item.completed 
      ) 
     }) 
    </script>
  • 2

    Syntax

    Which of the following options describes the correct syntax for defining a computed property in Vue 3?

  • 3

    Access

    How can you unwrap and access a computed property named completedList in script section of a Vue 3 component?

  • 4

    Access

    How can you access the computed property named completedList in the template area of a Vue 3 component?

  • 5

    Writable computed property

    Computed properties are by default getter-only. However, writable computed property can be defined by passing both and functions.
  • Computed property vs method...

    A computed property will only re-run when reactive variables used inside have changed.

    This means, in our earlier example, as long as an individual item status in items array has not changed, multiple access to completedList will immediately return the previously computed result without having to run the getter function again, unlike method invocation which will always run the function whenever a re-render happens.

  • 7

    Caching

    Which one of the following statements is true for computed properties?

  • 8

    Usecase

    Computed properties in Vue.js 3 are best suited for:

  • 9

    Usecase

    Which of the following scenarios are an appropriate use-cases for a computed property?

  • 10

    Behaviour

    Which of the following statements accurately describes the behaviour of a computed property?

  • 11

    Advantages

    What is the main advantage of using a computed property with the Composition API in Vue.js 3?