📘 Day 64: JavaScript Number Methods & Non-Primitive Data Types 🔹 toFixed() – Rounds numbers to a fixed number of decimal places • Adds zeros if decimals are not present • toFixed(0) rounds to nearest whole number • Rounds up or down based on decimal value 🔹 toPrecision() – Sets the total number of digits in a number • Controls overall number length, not just decimals • Useful for formatting numeric output 💡 Non-Primitive Data Types: • Array – Stores multiple values in one variable • Object – Stores data in key–value pairs • Map – Collection of keyed data (any data type as keys) • Set – Collection of unique values #JavaScript #Day64 #WebDevelopment #FrontendDevelopment #CodingJourney #JSBasics #LearningJavaScript #NumberMethods #NonPrimitiveDataTypes
JavaScript Number Methods & Non-Primitive Data Types Explained
More Relevant Posts
-
Primitive data types are the basic types of data in JavaScript. They represent single values and are not objects. JavaScript has seven primitive data types. String is used to store text values, such as "Hello". Number is used to store numeric values like 10 or 3.14. Boolean represents logical values: true or false. Undefined means a variable has been declared but not given a value. Null represents an intentional empty or unknown value. Symbol is a unique identifier introduced in ES6. BigInt is used to store very large integers beyond the normal number limit.
To view or add a comment, sign in
-
-
👋 Hello LinkedIn Network, Understanding data types is essential for writing reliable JavaScript applications. A data type defines the kind of value a variable holds. JavaScript uses data types to determine how operations should behave. The most commonly used data types include: 🔹 String – represents text values 🔹 Number – represents numeric values 🔹 Boolean – represents true or false Example: let name = "Arjun"; // String let age = 21; // Number let isStudent = true; // Boolean Why does this matter? Because JavaScript behaves differently depending on the data type. For instance: console.log(5 + 5); // 10 console.log("5" + "5"); // 55 Proper understanding of data types prevents logical errors and improves code quality. For developers starting their journey in web development, mastering data types is a foundational skill. #JavaScript #WebDevelopment #Programming #FrontendDevelopment #Coding #TechEducation #LearnToCode
To view or add a comment, sign in
-
𝐈 𝐫𝐞𝐛𝐮𝐢𝐥𝐭 𝐂𝐑𝐔𝐃 𝐭𝐡𝐞 𝐰𝐚𝐲 𝐈 𝐭𝐡𝐢𝐧𝐤 𝐢𝐭 𝐬𝐡𝐨𝐮𝐥𝐝 𝐛𝐞 𝐥𝐞𝐚𝐫𝐧𝐞𝐝. No backend. No database. Just 3 files: → index.html → style.css → script.js The logic lives in one place → an array. Add → push() into the array Delete → filter() by id Update → find() and modify Render → rebuild the list from the current data That’s the whole system. What this project reinforces: → Data is your single source of truth → UI only reflects what your data contains → Nothing updates unless you explicitly tell it to This is why I like revisiting fundamentals. When you understand CRUD at this level, frameworks stop feeling complex... They automate patterns you already know. Small project. Strong control over data. . . . ➥ Tags: #JavaScript #BackendDevelopment #SoftwareEngineering #WebDevelopment #FatimaHamid
To view or add a comment, sign in
-
Arrays store data by position. Objects store data by identity. I wrote a deep breakdown of 𝐉𝐚𝐯𝐚𝐒𝐜𝐫𝐢𝐩𝐭 𝐎𝐛𝐣𝐞𝐜𝐭𝐬. Instead of treating them as just another data structure, the article explores how objects help us model real-world data. Key ideas covered: • Why 𝐢𝐝𝐞𝐧𝐭𝐢𝐭𝐲 𝐦𝐚𝐭𝐭𝐞𝐫𝐬 𝐦𝐨𝐫𝐞 𝐭𝐡𝐚𝐧 𝐩𝐨𝐬𝐢𝐭𝐢𝐨𝐧𝐚𝐥 𝐨𝐫𝐝𝐞𝐫 when structuring data • When to use 𝐝𝐨𝐭 𝐧𝐨𝐭𝐚𝐭𝐢𝐨𝐧 𝐯𝐬 𝐛𝐫𝐚𝐜𝐤𝐞𝐭 𝐧𝐨𝐭𝐚𝐭𝐢𝐨𝐧 • How 𝐢𝐧𝐭𝐞𝐠𝐞𝐫-𝐥𝐢𝐤𝐞 𝐤𝐞𝐲𝐬 𝐚𝐟𝐟𝐞𝐜𝐭 𝐩𝐫𝐨𝐩𝐞𝐫𝐭𝐲 𝐨𝐫𝐝𝐞𝐫𝐢𝐧𝐠 in JavaScript objects • Using 𝐒𝐲𝐦𝐛𝐨𝐥𝐬 to attach unique, non-colliding metadata • How 𝐎𝐛𝐣𝐞𝐜𝐭.𝐬𝐞𝐚𝐥() and 𝐎𝐛𝐣𝐞𝐜𝐭.𝐟𝐫𝐞𝐞𝐳𝐞() help control mutation I also introduce how 𝐦𝐞𝐭𝐡𝐨𝐝𝐬 𝐚𝐧𝐝 𝑡ℎ𝑖𝑠 𝐚𝐥𝐥𝐨𝐰 𝐨𝐛𝐣𝐞𝐜𝐭𝐬 𝐭𝐨 𝐜𝐨𝐦𝐛𝐢𝐧𝐞 𝐝𝐚𝐭𝐚 𝐰𝐢𝐭𝐡 𝐛𝐞𝐡𝐚𝐯𝐢𝐨𝐫. If you're building a strong mental model of JavaScript fundamentals, this piece might help. Read here: https://lnkd.in/dRQzGc6B Chai Aur Code #javascript
To view or add a comment, sign in
-
-
JavaScript arrays become much easier once you understand these methods: push() → add to end pop() → remove from end shift() → remove from start unshift() → add to start map() → transform data filter() → select data reduce() → combine values I explained each one with simple examples for beginners Read the full blog: https://lnkd.in/gSS7HKvB
To view or add a comment, sign in
-
🚀 Day 20 (Part 2): Handling "Dirty" Data in Automation 🧹 --Practice--Regex--String Manipulation-- In real apps, prices aren't just numbers (500). They are strings like "$500" or "USD 500.00". If you try Number("$500"), JavaScript gives you NaN. Script Failed. ❌ The Fix? Data Cleaning with Regex. 💡 Code Snippet: let price = "$500.00"; let cleanPrice = price.replace(/[^0-9.]/g, ""); // Result: "500.00" Now my automation script doesn't care if the dev changes the currency symbol from $ to USD. It extracts the number regardless! Code snippet 👇 ! #JavaScript #CodingJourney #LearningInPublic #NodeJS #TestAutomation #SDET #WebDevelopment #QualityAssurance
To view or add a comment, sign in
-
-
#JavaScript | #Day5 Today, I learned about Data Types in JavaScript — one of the most important foundations for writing clean and error-free code. JavaScript has two main categories of data types: 1️⃣ Primitive Data Types Primitive data types are the most basic types of data in JavaScript. 👉 They store single, simple values. 👉 They are immutable (their values cannot be changed directly). 👉 They are stored by value (not by reference). 🔹 Types of Primitive Data Types 1️⃣ Number : Used to store numeric values (integers and decimals). 2️⃣ String : Used to store text values. 3️⃣ Boolean : Represents logical values: true or false. 4️⃣ Undefined : A variable declared but not assigned a value. 5️⃣ Null : Represents an intentional empty value. 6️⃣ Symbol : Used to create unique identifiers. 2️⃣ Non-Primitive Data Types Non-primitive data types (also called Reference types) are used to store collections of data or more complex values. 👉 They store multiple values 👉 They are stored by reference (memory address) 👉 They are mutable (can be changed after creation) 🔹 Types of Non-Primitive Data Types 1️⃣ Object : An object stores data in key-value pairs. Used to represent real-world entities. 2️⃣ Array : An array stores multiple values in a single variable. Used to store lists of data. 3️⃣ Function : A function is a reusable block of code. functions are also objects. 4️⃣ Map : Stores key-value pairs. ✔ Keys can be any data type ✔ Maintains insertion order 5️⃣ Set : Stores unique values (no duplicates). 6️⃣Regular Expression : Used for pattern matching. #Day5 #JavaScript #WebDevelopment #FullStackDeveloper #LearningJourney #10000Coders #Consistency #BeginnerDeveloper 10000 Coders
To view or add a comment, sign in
-
-
🛑 "Using Nested For-Loop" JavaScript has evolved significantly, but many of us still rely on outdated nested loops, a major bottleneck for performance optimization. If your code looks like the left side of this image, it’s time for an upgrade. Check out this quick breakdown of why nested loops are inefficient and how modern alternatives can revolutionize your data processing: 🔹 The "Don't": Standard nested loops create high overhead and are difficult for the browser to optimize and slow in querying database. They lead to slow code execution. 🔹 The "Do": Modern, clean alternatives like .forEach(), .map(), .filter(), and .reduce(). These methods are not only more readable but also leverage modern engine optimizations for massive speed boosts. Don't let legacy coding habits hold your application back. Embrace the efficiency of modern JavaScript. #JavaScript #CodingBestPractices #SoftwareEngineering
To view or add a comment, sign in
-
-
🚀 Day -1: Deep Dive into JavaScript Data Types Today I revised one of the most important JavaScript fundamentals — Primitive vs Non-Primitive Data Types. Understanding this clearly helps a lot in interviews, debugging, and writing efficient code. 🔹 Primitive Data Types Number, String, Boolean Undefined, Null BigInt, Symbol ✅ Key Points Immutable (values cannot be changed) Stored in Stack Memory Passed by value Example: Changing one variable does not affect another because each has its own copy. 🔹 Non-Primitive (Reference) Data Types Object Array Function ✅ Key Points Mutable (values can be modified) Stored in Heap Memory Passed by reference Example: Updating one object can affect another variable pointing to the same reference. 💡 This concept explains many real-world JavaScript issues like: Unexpected object changes Shallow vs deep copy Why const objects can still change 📌 Consistency + Fundamentals = Strong Developer Foundation #JavaScript #WebDevelopment #Programming #LearningJourney #Frontend #SoftwareEngineering #DSA #GATECSE
To view or add a comment, sign in
-
𝗧𝗵𝗲 𝗨𝗹𝗧𝗶𝗺𝗮𝗧𝗲 𝗚𝗨𝗶𝗱𝗲 𝗧𝗼 𝗝𝗮𝗩𝗮𝗦𝗰𝗿𝗶𝗽𝗧 𝗠𝗮𝗽, 𝗦𝗲𝗧, 𝗪𝗲𝗮𝗸𝗠𝗮𝗽, 𝗮𝗻𝗱 𝗪𝗲𝗮𝗸𝗦𝗲𝗧 If you want to master modern JavaScript, you need to understand Map, Set, WeakMap, and WeakSet. They solve problems that Object and Array cannot, especially when it comes to performance, memory, and data safety. - Map stores key-value pairs like objects, but is more powerful. - Set stores unique values only. - WeakMap and WeakSet are used for private data and tracking objects. Here are the core methods for each: - Map: set, get, has, delete, clear, size - Set: add, has, delete, clear, size - WeakMap: set, get, has, delete - WeakSet: add, has, delete You can loop through Map and Set using for...of, keys, values, and entries. For example: - for (const [key, value] of map) { console.log(key, value); } - for (const value of set) { console.log(value); } You can also convert between Map, Object, and Array using Object.fromEntries and Array.from. Source: https://lnkd.in/dU6PmUSF
To view or add a comment, sign in
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development