Although @airdrumz solutions works, you will get lots of errors about you doing it wrong by accessing ID directly, this is not good for future compatibility.
But it lead me to inspect the object and create this OOP approach:
function myplug_get_prod_attrs() {
// Enqueue scripts happens very early, global $product has not been created yet, neither has the post/loop
global $product;
$wc_attr_objs = $product->get_attributes();
$prod_attrs = [];
foreach ($wc_attr_objs as $wc_attr => $wc_term_objs) {
$prod_attrs[$wc_attr] = [];
$wc_terms = $wc_term_objs->get_terms();
foreach ($wc_terms as $wc_term) {
array_push($prod_attrs[$wc_attr], $wc_term->slug);
}
}
return $prod_attrs;
}
Bonus, if you are performing the above early before the global $product item is created (e.g. during enqueue scripts), you can make it yourself with:
$product = wc_get_product(get_queried_object_id());