console.log() |
Outputs a message to the console |
console.log('Hello'); |
alert() |
Displays an alert dialog |
alert('Hello'); |
document.getElementById() |
Gets an element by its ID |
document.getElementById('demo'); |
document.querySelector() |
Selects the first element matching a CSS selector |
document.querySelector('.class'); |
addEventListener() |
Attaches an event listener to an element |
element.addEventListener('click', function); |
innerHTML |
Gets or sets the HTML content |
element.innerHTML = 'New content'; |
textContent |
Gets or sets the text content |
element.textContent = 'New text'; |
Array.length |
Returns the length of an array |
arr.length; |
Array.push() |
Adds elements to the end of an array |
arr.push('item'); |
Array.pop() |
Removes the last element from an array |
arr.pop(); |
String.length |
Returns the length of a string |
str.length; |
String.toUpperCase() |
Converts a string to uppercase |
str.toUpperCase(); |