How to add a class to the body element?

After some searching I’ve now found another piece of code that uses ‘hide’ API, which should hide an object, which could be a better way of doing things:

import { authentication } from 'wix-members';

$w.onReady(function () {
  const loggedIn = authentication.loggedIn();

  if (loggedIn) {
    console.log('Logged in, hiding Resources menu item');
    $w('#comp-kd49gw7q3').hide();
  }

  authentication.onLogin(() => {
    console.log('Logged in, hiding Resources menu item');
    $w('#comp-kd49gw7q3').hide();
  });
});

I got the code snippet from Wix help pages: https://www.wix.com/velo/reference/$w/breadcrumbs/hide

But even though I’ve added it to the masterpage.js it does not work. I get an error “Hide is not a function”. This is Wix’s code and does not work for me! What am I missing here?