I am super excited to kick off my journey in React Native! Building mobile apps has always been a dream of mine, and today, I took the first step towards making it a reality.
My focus today was on Variables (var, let, const) and Data Types (strings, numbers, arrays, booleans, and objects). Here's what I learned:
Variables (VAR, LET, CONST)
Understanding the differences between these three was eye-opening:
var: Can be reassigned and redeclared. It has function scope, which makes it more exposed and less secure in modern coding practices.
let: Can be reassigned but not redeclared. It uses block scope, making it safer and more preferred than var.
const: Cannot be reassigned or redeclared. Like let, it has block scope. It's perfect for values that should remain constant.
One takeaway: if a value shouldn't change, always use const. It ensures your code stays clean and predictable.
Data Types
Here's a quick breakdown of the data types I explored today:
Strings: A string is any text enclosed in either double quotes (" ") or single quotes (' '). For example, "Hello, world!" is a string.
Numbers: Any numeric value from 0 - 9, like 42 or 3.14, belongs to the number type.
Arrays: Think of an array as a collection of values stored in a single variable. For example, [1, 2, 3] or ['apple', 'banana', 'cherry'].
Booleans: This data type has only two possible values: true or false. It’s great for decision-making in code.
Objects: Objects are collections of related data in key-value pairs. For instance:
const person = { name: 'Jane', age: 25, greet: function () { return 'Hello!'; } };
Objects can even include methods (functions) that belong to the object itself!
Final Thoughts
Overall, today was a beautiful learning ride. I feel more confident about the basics and can't wait to dive deeper tomorrow.
If you're also starting out or looking for a reason to learn React Native, why not join me on this daily challenge/ride? Let's build something amazing together!
Stay tuned for Day 2!
The above is the detailed content of My React Journey Day1. For more information, please follow other related articles on the PHP Chinese website!