Sep 3, 2024
<script>
tags at the bottom of the HTML body.<script>
tags.console.log()
for outputting values while debugging.console.error()
, console.warn()
, console.table()
, etc.var
, let
, and const
.
var
: globally scoped, not recommended in modern JavaScript.let
: block-scoped, allows reassignment.const
: block-scoped, cannot be reassigned.const name = 'John'; // String
const age = 30; // Number
const isCool = true; // Boolean
const rating = 4.5; // Number
const x = null; // Null
let y; // Undefined
+
and template literals (``
).string.length
string.toUpperCase()
string.substring(start, end)
const fruits = ['apple', 'orange', 'pear'];
fruits[1]
returns 'orange'..push()
, .pop()
, .shift()
, .unshift()
, .indexOf()
, etc.const person = {
firstName: 'John',
lastName: 'Doe',
age: 30
};
person.firstName
.const { firstName, lastName } = person;
class Person {
constructor(firstName, lastName) {
this.firstName = firstName;
this.lastName = lastName;
}
}
document.getElementById()
, document.querySelector()
, document.querySelectorAll()
.addEventListener()
for handling user interactions.