Normal Objects

Learn how to create and use plain objects for grouping related data and behavior in BornomalaScript.

Normal Objects

Normal objects are a simple way to group related values and functions together.

They are useful when you want one variable to hold several pieces of information about the same thing.

Example of a Simple Object

Example of a simple object:

dhoro nam = "Mahfuz"
dhoro amarObject = {
    name: nam,
    age: 20,
    amarKaj: (n) {
        lekho(n)
    },
    JogKoro: (x,y,z,n,t,i) {
        ferotDao x + y + z + n + t + i
    },
    myArr: ["item1", "item2", "item3", "item4", "item5"],
    myArr2: [
        "item1", "item2", "item3", "item4", "item5"
    ],
    car: {
        color: "black",
        speed: "44kmh"
    }
}
lekho(amarObject.name)
lekho(amarObject.age)
amarObject.amarKaj("korbo na")
dhoro jogFol = amarObject.JogKoro(4,4,4,4,4,4)
lekho(f"jogFol = {jogFol}")
lekho(amarObject.myArr[0])
lekho(amarObject.myArr2[1])
lekho(amarObject.car.color)
lekho(amarObject.car.speed)

How It Works

The object stores:

  • simple values like name and age
  • methods like amarKaj
  • arrays like myArr and myArr2
  • nested objects like car

That means an object can hold many related values in one structure.

Why Normal Objects Matter

Normal objects are useful when:

  • you want to store information about one item
  • you want to group data and behavior together
  • you want to access values by property name

Step-by-Step Breakdown

  1. Create a variable to hold text
  2. Create an object with properties and methods
  3. Read values using dot notation
  4. Call methods from the object
  5. Access nested arrays and objects when needed

Why This Example Is Useful

This example shows that objects can store more than just plain values.

They can also hold:

  • reusable behavior
  • arrays
  • nested structures

That makes them a very flexible tool in programming.

Common Mistakes

Beginners often make these mistakes:

  • using confusing property names
  • forgetting dot notation
  • mixing up arrays and objects
  • making objects too large and hard to read

Try These Variations

Try building your own object for:

  1. A student
  2. A book
  3. A car

Add a few properties and at least one method.

Quick Checklist

Before moving on, make sure you can:

  • create an object
  • access a property
  • call a method
  • read nested values

If yes, you understand the basics of normal objects.