Education logo

JAVASCRIPT OBJECTS

JAVASCRIPT OBJECTS FOR BEGINNERS

By bk_bharathikannanPublished 3 years ago 3 min read
JAVASCRIPT OBJECTS
Photo by Mohammad Rahmani on Unsplash

OBJECT

The object type represents one of Javascript datatypes.Objects contains “key and values” .

{ } ->Represents an empty object

let empty_object = {};

Spaces and line breaks are not important

let phone = {type:”iphone”, model:”13pro”, color:"white"};

* In this above line contains keys and values ......

keys are type, model,color.....

* Suppose you put keys in double word like data base

use double quotation ("data base")

* Whenever we put an values they should be declared in double quotation or single quotation,Except intergers

values are "iphone","13pro", "white".....

HOW TO CALL OBJECT ⬇️

let object= {

FirstName : "pikachu",

LastName : "bk",

age : 18

};

console.log(object)

output:-

{FirstName: 'pikachu', LastName: 'bk', age: 18}

if you want only first_name You can use dot/bracket notation

-Bracket notation[]

console.log(object['FirstName']);

-Dot notation .

console.log(object.FirstName);

**Little more advanced concept in obj**

-let input = “FirstName”;

-let data= {

FirstName : “pikachu”,

LastName : “bk”,

age : 18

};

console.log(object.input);

output:-

undefined

Because we dont have input as a field in data.suppose we use bracket

notation we get output.

For example

console.log(object[input]);

output:-

pikachu

Object.keys()

const data = {

a: ‘pikachu’,

b: 42,

c: false

};

console.log(Object.keys(data));

output:-

(3) [‘a’, ‘b’, ‘c’]

Object.values()

const object1 = {

a: ‘somestring’,

b: 42,

c: false

};

console.log(Object.values(object1));

output:-

(3) [“somestring”, 42, false]

Object.entries()

const obj = {

first_name: 'pikahu',

last_name: "bk"

};

console.log(Object.entries(obj));

-output:-

(2) [Array(2), Array(2)]

1. 0 :(2)['first_name', 'pikahu']

2. 1: (2) ['last_name', 'bk']

Math objects:- ⬇️

console.log(Math.PI);

output:-

3.141592653589793

const values = 5.8;

console.log(Math.round(values));

➡️ 6

console.log(Math.floor(values));

➡️ 5

console.log(Math.ceil(values));

➡️ 6

console.log(Math.trunc(values));

➡️ 5

Math.random

console.log(Math.random());

Whenever we use math.random function....we get random numbers in our output.......

Returns a random integer from 0 to 9

console.log (Math.floor(Math.random() * 10));

Returns a random integer from 0 to 100

console.log (Math.floor(Math.random() * 100));

❤️“Have a Fine_Day”❤️

MORE ABOUT JS OBJECTS:

JavaScript objects are a fundamental part of the JavaScript programming language. They are used to store and organize data, and can be used to create complex and dynamic web applications.

An object in JavaScript is a collection of properties, each of which has a name and a value. Properties can be any type of data, including numbers, strings, booleans, and even other objects. Objects can be created using the object literal notation, which is denoted by curly braces ({}), or by using the object constructor function, which is the "Object" function.

One of the most powerful features of JavaScript objects is their ability to store and manipulate data in a dynamic and flexible way. For example, a simple object can be used to store information about a person, such as their name, age, and address. This object could then be used to display this information on a web page, or to save it to a database.

JavaScript objects also support inheritance, which allows objects to inherit properties and methods from other objects. This allows for the creation of complex object hierarchies, and makes it easy to reuse and extend existing code.

Another important feature of JavaScript objects is their ability to be used as a map, or associative array. This means that properties can be accessed using their name as a string key, rather than by their index. This makes it easy to work with large amounts of data and to organize it in a logical way.

In addition to these core features, JavaScript objects also support a wide range of methods and properties that can be used to manipulate and work with data. These include methods for iterating through properties, for getting and setting property values, and for adding and removing properties.

In conclusion, JavaScript objects are a powerful and versatile feature of the JavaScript programming language. They allow for the storage and manipulation of data in a dynamic and flexible way, and provide a wide range of methods and properties for working with that data. Understanding the basics of JavaScript objects is essential for any developer working with JavaScript, and will open the door to creating complex and dynamic web applications.

THINK TWICE💭-code once!

THANKS_FOR_READING_!🌟

❤️“Have a Fine_Day”❤️

coursesstudent

About the Creator

bk_bharathikannan

YOUNG FRONTEND DEVELOPER

Reader insights

Be the first to share your insights about this piece.

How does it work?

Add your insights

Comments (1)

Sign in to comment
  • bk_bharathikannan (Author)3 years ago

    ❤️

Find us on social media

Miscellaneous links

  • Explore
  • Contact
  • Privacy Policy
  • Terms of Use
  • Support

© 2026 Creatd, Inc. All Rights Reserved.