JavaScript_BTech_Notes
JavaScript_BTech_Notes
- Object: Key-value pairs (e.g., let person = { name: "John", age: 22 };)
Example:
let student = {
name: "Ravi",
rollNo: 101,
department: "CSE"
};
Accessing properties:
console.log(student.name); // Ravi
DOM (Document Object Model) is a tree-like structure created by the browser from the HTML
document.
- JavaScript can use the DOM to change content, styles, and structure.
Example:
<script>
</script>
4. How to validate email and mobile number using regular expressions in JavaScript?
Email Validation:
function validateEmail(email) {
return regex.test(email);
}
Mobile Number Validation (10 digits, optional country code):
function validateMobile(number) {
return regex.test(number);