Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

166
Views
Javascript method/shorthand that is used to control HTML video elements

Earlier I was following a tutorial about building a custom HTML video player. It's pretty basic but that tutorial indroduced some kind of shorthand in javascript to access the video element. Just curious about it.

So let's say, this is my video element:

<video class="viewer" src="652333414.mp4"></video>

Here is how I get the element and have a function to change state of the element

const video = document.querySelector(".viewer");

function togglePlay(){
    const method = video.paused ? 'play' : 'pause';
    video[method]();

    console.log(video[method]());
}

I understand video.paused is used to determine the video playing state. And the method variable gets the method name (string) which we want to execute. Now check this line video[method]();, I am curious about this syntax/shorthand/method.

By the way, it returns a promise.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!