Skip to content

Instantly share code, notes, and snippets.

@cmbaughman
Created February 6, 2025 18:26
Show Gist options
  • Save cmbaughman/a4cafb54108e79756891448771c2b14e to your computer and use it in GitHub Desktop.
Save cmbaughman/a4cafb54108e79756891448771c2b14e to your computer and use it in GitHub Desktop.
Wild Javascript APIs
// Get connection speed
if (navigator.connection) {
const downlink = navigator.connection.downlink;
console.log(`Current download speed: ${downlink} Mbps`);
}
else {
console.log("Network Information API not supported");
}
// Mobile device vibrate
if (navigator.vibrate) {
navigator.vibrate(500); // in milliseconds
}
// Group console.logs
console.group('Group Label');
console.log('Log message 1');
console.log('Log message 2');
console.groupEnd();
// See all of an object's properties
const obj = { prop1: 'Test', prop2: 22222 };
console.dir(obj);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment