DEV Community

Tamilselvan K
Tamilselvan K

Posted on

Day -18"πŸš€ My JavaScript Journey Begins: Understanding the Basics"

JavaScript Basics: Data Types, Variables, Functions, and More πŸ˜„

Today, I continued my JavaScript journey by diving into some of the core concepts that every developer needs to know. Here's a breakdown of what I learned and some examples that helped me understand things better πŸš€

1. Data Types in JavaScript

JavaScript supports several basic data types:

  • String – Text enclosed in quotes
  let name = "Tamil";
Enter fullscreen mode Exit fullscreen mode
  • Number – Integers or floating-point numbers
  let age = 25;
Enter fullscreen mode Exit fullscreen mode
  • Boolean – true or false
  let isStudent = true;
Enter fullscreen mode Exit fullscreen mode
  • Undefined – A variable declared but not assigned
  let score;
Enter fullscreen mode Exit fullscreen mode
  • Null – Intentionally empty
  let result = null;
Enter fullscreen mode Exit fullscreen mode

2. Variables πŸ“

Variables are used to store data values. You can declare them using var, let, or const.

let city = "Coimbatore";
const country = "India";
Enter fullscreen mode Exit fullscreen mode

I learned that const is used when we don't want to reassign a value, while let allows reassignment 😊

3. Functions βš™οΈ

Functions are blocks of reusable code. They help us avoid repeating code.

Function Declaration

function greet() {
  console.log("Hello, World!");
}
Enter fullscreen mode Exit fullscreen mode

Calling a Function

greet(); // Output: Hello, World!
Enter fullscreen mode Exit fullscreen mode

4. Parameters and Return Values πŸ“©

Functions can take inputs (parameters) and return outputs using the return keyword.

function add(a, b) {
  return a + b;
}

let sum = add(5, 10);
console.log(sum); // Output: 15
Enter fullscreen mode Exit fullscreen mode

5. String Concatenation πŸ”—

Joining strings together is called concatenation.

let firstName = "Tamil";
let lastName = "Selvam";
let fullName = firstName + " " + lastName;
console.log(fullName); // Output: Tamil Selvam
Enter fullscreen mode Exit fullscreen mode

I found it exciting to see how functions and variables work together to create dynamic outputs! 😍


Final Thoughts πŸ’­

Learning these foundational concepts is like building blocks for my JavaScript journey. I feel more confident now in writing basic code and understanding how logic flows in a program πŸ’ͺ. Tomorrow, I’ll be moving on to conditional statements and loops!

Thanks for reading! If you're also learning JavaScript, feel free to connectβ€”we can grow together 🀝


Top comments (0)