JavaScript Doesn't Have Classes! Yes, that's correct. Anyone who started using JavaScript after 2015 will be very confused by this statement. "But I saw the class syntax in the intro course I took when I started programming!" Which would also be accurate. JavaScript has a syntax for classes, but under the hood, no class in the Java/C++ sense is being declared. Don't believe me? Go run this in your browser console: class Test { constructor() { this.prop = "test"; } } console.log(typeof Test); Yes, it's a function. JavaScript classes essentially do two things: create a constructor function that works with the "new" keyword, and set up a prototype object (more on that another time). "Okay, but it's still basically a class." No, not really. Try this code (hopefully you tried the one above first): let x = new Test(); Now you have a Test object with one property, "prop". Now do this: x.newprop = "newprop"; This runs. In most other languages, this would be grounds for the compiler to crash your IDE out of pure spite. It runs in JavaScript because the class was never acting as a blueprint, it was just a special constructor function all along. If you've always been confused by the __proto__ property when checking Javascript objects and too scared to ask what it is, well it's part of the same conspiracy, I will be writing about it in my next post #javascript #webdevelopment #programming
JavaScript Classes: Not What You Think
More Relevant Posts
-
💡 Same function name. Same call. Different languages… different outcomes. Here’s a simple comparison 👇 🔹 JavaScript ```javascript function add(a, b) { return a + b; } function add(a, b, c) { return a + b + c; } console.log(add(1, 2, 3, 4)); ``` 👉 Output: 6 (extra argument is ignored, last function overrides previous) 🔹 C# ```csharp void Add(int a, int b) { } void Add(int a, int b, int c) { } Add(1, 2, 3, 4); ``` 👉 Output: Compile-time error ❌ (No method matches 4 parameters) ⚖️ Key Comparison: ✔ JavaScript • Flexible with arguments • Ignores extra values • Function overriding (last one wins) • Can silently introduce bugs ✔ C# • Strong method overloading • Strict parameter matching • No extra arguments allowed • Errors caught early 🎯 Takeaway: What works in one language may fail in another. #JavaScript #CSharp #Programming #Developers #CodingTips #Tech
To view or add a comment, sign in
-
📘 𝐉𝐚𝐯𝐚𝐒𝐜𝐫𝐢𝐩𝐭 𝐈𝐧𝐭𝐞𝐫𝐯𝐢𝐞𝐰 𝐌𝐨𝐝𝐮𝐥𝐞 (𝐁𝐚𝐬𝐢𝐜) 𝐒𝐞𝐜𝐭𝐢𝐨𝐧 1: 𝐁𝐚𝐬𝐢𝐜 𝐉𝐚𝐯𝐚𝐒𝐜𝐫𝐢𝐩𝐭 (𝐓𝐡𝐞 𝐟𝐮𝐧𝐝𝐚𝐦𝐞𝐧𝐭𝐚𝐥𝐬 𝐨𝐟 𝐉𝐚𝐯𝐚𝐒𝐜𝐫𝐢𝐩𝐭) 1. What is JavaScript? 2. If you want to use JavaScript in your code editor, what do you need to run? 3. How to see JavaScript output? 4. What is WWW? 5. Who created JavaScript? 6.Describe something Before without JavaScript and After using JavaScript in website? 7. How many types of programming languages can we use? 8.Which type of programming language is JavaScript? 9. What is an interpreted / JIT language? 10. What is a compiled language / What is compiled? 11. Difference between compiled vs interpreted language? 12. What is JavaScript Engine or V8 Engine? 13. What are JavaScript comments? 14. What is immutable and mutable? 15. What is primitive and non-primitive? 🎯 𝐈𝐧𝐭𝐞𝐫𝐯𝐢𝐞𝐰 𝐐𝐮𝐞𝐬𝐭𝐢𝐨𝐧𝐬 (𝐄𝐱𝐭𝐫𝐚) 1. Why is JavaScript called a single-threaded language? 2. What is event loop in JavaScript? 3. What is JIT (Just-In-Time) compilation? 4. Why JavaScript is so popular in web development? 5. Does JavaScript only run in browsers? #DotNet #AspNetCore #MVC #FullStack #SoftwareEngineering #ProgrammingTips #DeveloperLife #LearnToCode #JavaScript #JS #JavaScriptTips #JSLearning #FrontendDevelopment #WebDevelopment #CodingTips #CodeManagement #DevTools
To view or add a comment, sign in
-
-
🚀 JavaScript Simplified Series — Day 14 You already know how to: ✔ Transform data → map() ✔ Filter data → filter() ✔ Combine data → reduce() But what if you want to: 👉 Find just ONE element? 👉 Check if ANY condition is true? 👉 Check if ALL elements satisfy a condition? This is where Advanced Array Methods come in. 🔹 1. find() → Get first matching element let users = [10, 20, 30, 40] let result = users.find(num => num > 25) console.log(result) 👉 Output: 30 📌 find() returns the first matching value 🔹 2. some() → Check if ANY element matches let users = [10, 20, 30] let result = users.some(num => num > 25) console.log(result) 👉 Output: true 📌 some() returns true if at least one element matches 🔹 3. every() → Check if ALL elements match let users = [10, 20, 30] let result = users.every(num => num > 5) console.log(result) 👉 Output: true 📌 every() returns true if all elements match 🔥 Real Life Example Think of a classroom 🎓 find() → first student who passed some() → at least one student passed every() → all students passed 🔥 Simple Summary find → first match some → any match every → all match 💡 Programming Rule Don’t search manually. Use built-in methods smartly. If you want to learn JavaScript in a simple and practical way, you can follow these YouTube channels: • Rohit Negi • Hitesh Choudhary (Chai aur Code) Refrence video :- https://lnkd.in/dHYk9bwC 📌 Series Progress Day 1 → What is JavaScript Day 2 → Variables & Data Types Day 3 → Type Conversion & Operators Day 4 → Truthy & Falsy + Comparison Operators Day 5 → If Else + Switch + Ternary Day 6 → Loops Day 7 → Break + Continue + Nested Loops Day 8 → Functions Basics Day 9 → Arrow + Default + Rest Parameters Day 10 → Callback & Higher Order Functions Day 11 → Arrays Basics Day 12 → Array Methods (Basic) Day 13 → Array Iteration (map, filter, reduce) Day 14 → Advanced Array Methods Day 15 → Objects (Next Post) Follow for more 🚀 #JavaScriptSimplified #javascript #webdevelopment #coding #programming #learninpublic #100DaysOfCode #frontenddevelopment #devcommunity #codingjourney #softwaredeveloper #techcommunity #dailylearning #codeeveryday
Array part 2 in Javascript Hindi | chai aur #javascript
https://www.youtube.com/
To view or add a comment, sign in
-
🧠 What makes JavaScript OOP different? When I first learned OOP, I thought it was the same everywhere: Classes, inheritance, objects… done. But JavaScript works differently. 👉 It’s NOT truly class-based. Under the hood, JavaScript is prototype-based. That means: Objects inherit from other objects Behavior is shared through links, not copied There’s no “blueprint class” like in Java or C# 💡 Even when you write: class User {} 👉 JavaScript is still using functions + prototypes behind the scenes. 🔥 Why this matters: If you don’t understand this: ❌ this will confuse you ❌ inheritance will feel weird ❌ bugs will look “random” 🧠 My takeaway: In JavaScript, classes are just a friendly layer… but prototypes are the real system. Once you see that, JS stops feeling strange — and starts feeling logical. #JavaScript #OOP #WebDevelopment #Frontend
To view or add a comment, sign in
-
One of the fascinating things about JavaScript is how good a language it is despite having been thrown together in ten days with the bizarre constraint that it look like Java because Sun and Netscape were flirting. As I try to refine the developer experience of tjs to a finely honed edge I have the luxury of having no user base and a tireless peon who is willing to update all test code, examples, and documentation on a whim. Yesterday I changed the function signature syntax to be more intuitive for typescript coders. Claude implemented it as a deprecation and I said no, just purge the old syntax. We have no users so why make our code more complex or our examples ambiguous. It’s amazing to me that JavaScript got as far as it did with its obvious flaws (and strengths) without getting some crucial fixes before there were too many stakeholders to satisfy. typeof null == “object”… really? Semicolon insertion?! And it’s not like HyperCard hadn’t walked the same path more successfully nearly ten years earlier. HyperTalk was already compiling to assembler and writing system extensions at that point.
To view or add a comment, sign in
-
Javascript: NaN ⚠️ JavaScript has a value that literally means “Not a Number”… but it is still a number type! Yes, that confusing value is called NaN. Many beginners get surprised when they see it in their code. Let’s simplify it. NaN stands for Not a Number, and it appears when JavaScript fails to convert something into a valid number. Example situations: • Trying to divide something impossible → 0 / 0 • Converting text into numbers → Number("Hello") • Invalid math operations → Math.sqrt(-1) • Parsing wrong values → parseInt("abc") Important things to remember: • typeof NaN is "number" 🤯 • NaN is not equal to itself (NaN === NaN → false) • Use Number.isNaN() to properly check it • It often appears during data validation bugs Understanding NaN helps you avoid hidden bugs in JavaScript applications. Small concept… but very important for debugging. #JavaScript #WebDevelopment #FrontendDevelopment #LearnToCode #ProgrammingTips #JavaScriptBasics #CodingForBeginners #SoftwareEngineering #DevCommunity #100DaysOfCode
To view or add a comment, sign in
-
-
Recommendation for Your Next Skill to Unlock: Quarto + Observable JS 🔓 As you may know, I'm passionate about Quarto and have a background in R and Python. Recently, I discovered that Observable JS (OJS) is a powerful language, natively supported in Quarto, and it can upgrade your Quarto builds. The elephant in the room: JavaScript can be daunting for analysts who started with statistics, data querying, and data visualization. However, learning OJS feels more approachable—possibly because it's still data-centric. For those who love free tools: If, like me, you use static hosting such as GitHub Pages or quarto.pub, OJS is for you! I used to think streaming real-time data on a static Quarto page was impossible—until I started exploring OJS. Browser interaction: OJS enables browser interactions that I've found hard to achieve with R and Python. In three weeks, I found two ways to leverage browser data for tasks I couldn’t accomplish otherwise. Bonus: You can perform data preparation in R or Python, then convert your objects into OJS for interactive visualization. Getting started: If OJS or JavaScript are new to you, start by reviewing the Quarto and ObservableHQ documentation. If you’re new to JavaScript, check out this introduction before programming: https://lnkd.in/eMGW6cKg. If you've avoided OJS or weren't aware of it, I hope this post inspires you to explore how it can enhance your projects. Share your OJS experiences in the comments! #data #quarto #ojs #js #r #python #posit #datavisualization #dataanalysis #dashboard #programming #work #skills
To view or add a comment, sign in
-
Day 11 of documenting my journey as a Front-End Developer — Introduction to JavaScript Today, I started learning JavaScript, and I had a big misconception at first—I thought JavaScript was an advanced version of Java. I learned that this is not true. JavaScript and Java are completely different languages. JavaScript was created by Brendan Eich and was originally called Mocha, then LiveScript, before being renamed JavaScript to attract Java developers. JavaScript is a high-level, interpreted programming language mainly used to make websites interactive. One thing that stood out to me is how JavaScript executes code—line by line (synchronously), meaning order matters. I also learned: . JavaScript files are saved as .js (e.g., app.js) . It is linked in HTML using: HTML <script src="app.js"></script> . The defer attribute is used when the script is placed in the <head> to delay execution until the HTML loads Interesting fact: Different browsers use different JavaScript engines: . Chrome ---V8 Engine . Firefox----- SpiderMonkey On comments I understood: . JavaScript uses // for single-line comments . /* */ can also be used (same as CSS) . But HTML comments (<!-- -->) do not work in JavaScript Lesson learned: Understanding the foundation of a language helps clear wrong assumptions before diving deeper. #FrontendDevelopment #JavaScript #WebDevelopment #LearningJourney #BeginnerMistakes #WomenInTech #softwareengineering #developer #learninginpublic #techcommunity #careergrowth
To view or add a comment, sign in
-
-
Dev Notes #06 JavaScript feels like a breath of fresh air. For the past several months, my focus has been almost entirely on Java and Spring Boot: annotations, dependency injection, bean lifecycles, REST API design. Backend development is deeply rewarding, but it demands a particular kind of discipline. Everything is structured, strongly typed, and explicit by design. So when I began picking up JavaScript and React last week, my first reaction was genuine surprise at how different the experience felt. No type declarations. Components as functions. UI that responds to state. Coming from Java, it initially felt almost too flexible. But as I moved beyond the syntax and started reasoning about how things actually work, the depth became apparent. One concept that stood out early was memoization, specifically React's useMemo hook. The premise is straightforward: cache the result of a computation and only recalculate when its dependencies change. What made it click for me was recognising the intent behind it. While working through a component that parsed and tokenized text at the word level, re-executing that logic on every render would have been unnecessary and wasteful. useMemo made the computation deliberate, run once, reuse until something meaningful changes. That mindset, being intentional about what executes and when is not unfamiliar. It is the same principle that drives query optimization and efficient API design on the backend. The layer is different; the thinking is the same. JavaScript offers flexibility that Java does not. But flexibility without understanding is just unpredictability. The more I explore the frontend, the more I find that strong fundamentals transfer across the stack. #JavaScript #React #WebDevelopment #Java #DevNotes
To view or add a comment, sign in
-
Did you know JavaScript can behave like Java? Not really — but it can fake it beautifully. Here's something I love about JavaScript that most beginners overlook: closures. Look at this pattern Instead of a class with private fields, we use a factory function that returns methods just like a Java object would expose getters and setters. getName() — returns the name getAge() — returns the age incrementAge() — mutates internal state What makes this powerful? The variables personName, personAge, and personJob are completely private. They can't be accessed directly from outside the function. You MUST go through the returned methods. This is a closure — the inner functions "close over" the outer scope and remember it even after the factory function has finished running. So when you call: person.incrementAge() person.getAge() you get 124. Because that personAge variable is alive, encapsulated, and mutable — all without a single class keyword. Java devs: does this feel familiar? It should. JavaScript doesn't need classes to give you encapsulation. Closures have always been there doing the heavy lifting. This is a great pattern when you want lightweight objects without the overhead of a full class definition. Drop a if this gave you a new way to think about JavaScript! #JavaScript #WebDevelopment #Programming #100DaysOfCode #SoftwareEngineering #JSClosures
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
function myClassA() { this.myProp = 123; } const instance = new myClassA(); function myClassB() { myClassA.call(this); this.nextProp = 111; } Same as class myClassB extends myClassA { ... } The Difference is, class methods go in prototype, but you can use ES5 prototype design pattern.