Understanding Object Type of JavaScript
I have joined and started learning Software development with ChaiCode Web dev Cohort 2026 and very excited😊
JavaScript has 8 data types . 7 are primitive and 1 is complex object type. This is summary of T- class of cohort on 26 feb, 2026
// Objects
//terminal
mkdir t-5
code . // current directory me vscode snip up
1-object.js
8 data types 7 + 1
// properties :
name-value pairs
// 2 ways of creeting objects
let claude = new Object() // object constructor syntax
let gemini = {} // object literal
let gpt = {
company : 'openai',
version:5.3,
releaseYear:2025
}
// accessing properties
// gpt.company
// new properties
// property can be any type
gpt.type = 'Large Language Model' ;
gpt.isMultiModel = true // multiModel means can do many things
// remove properties
delete gpt.type
// sonnet
let sonnet = {
company :"anthrophic",
version : 4.6,
"released on": 2026, // trailing comma
}
// multi word property must be quotated
// square bracket notation
sonnet["released on"]
// valid identifier
1. starting not from number
2. only $and _.
// property are string in objects
// expression as values as property name
const input = "company"
sonnet[input]
// property value shorthand
//params
function getLaptop(name, price) {
return {
brand : 'apple',
//property shorthand if key and value are same
name,
price
}
}
let myMac = getLaptop("M4 Air", 99_000) // args
// myMac
// check property exists or not
// ram propert or not
myMac.ram === undefined // conditional always return boolean
// in method
"ram" in myMac // is there or not // key in object
// hasOwnProperty
// looping the objects
// for in
for(let key in myMac) {
console.log(`\({key} : \){myMac[key]}`)
}
// objects are ordered in different fashion
const codes = {
// Asia
7 : 'Russia',
32:'Belgium',
91:'India',
// North America
1:'Canada',
52:'Mexico'
}
// codes { 1,4,32,52,91}
// integer properties got sorted in objects , other appear in creation order
for (let code in codes ) {
console.log(key)
}
// fixing it
{
'+7': 'Russia',
'+32' : 'Belgium',
'+91':'India'
}
//Non Numeric properties
// Array, Date, Promise, Error
//Ref and copying
// primitives are always copied as "value"
let like = "Radhika Das" ;
le love = like ;
console.log(like, love)
// like : Taylor Swift
like = 'Taylor Swift' ;
console.log(love)
// Object are stored and copied by reference
let artist = {
name : "Radhika Das ",
country : "UK"
}
let Kirtaniya = artist ;
artist.country = "England" ;
// artist === Kirtaniya ;
// store by reference
let a = {};
let b = {} ;
console.log(a === b )
// Const can't be modified then how we modified objects
const ev = {
name : "Mahindra be6",
}
ev.name = "BYD Seal" // new word : contracdictin
// ev
// we cannot do
ev = {name : "Thar"}
// cloning and merging
const org = {
k1 : 'V1',
k2 : 'V2',
}
// why to clone becz cannot copy by value it taken ref
const clone = {}
for (let key in org ) {
clone[key] = org[key] ;
}
// Object.assign(dest, soyrces .. )
let clone2 = Object.assign ({}, org) ;
// nested objects
const nestedObj = {
model,
version ,
capabilities : {
reasoning}
}
// capabilities are ref
// deep clone needed
structuredClone(nestedObj)
// nestedObj.capabilities.reasoning = false
// it not change in nestedClone
// 02- Garbage Collection
// Reachability
let temp = {
emial : "gibbesis@xyz.com",
valid : 5
}
// yes it is reachable
// temp
// after 5 minutes it becomes invalid
temp = null
// temp // it is not point to the temp obj
// Garbage collector will junk the data and free the memory
const movie = {
title : 'Ghosted',
release : 2023,
production : 'Apple TV',
}
function coStars (actor, actress) {
actor.coStar = actress;
actress.coStar = actor
return {
leading : actor,
supporter:actress
}
}
movie.cast = coStars({
name : 'Chris Evan' , salary : 10_000_000},
{name: 'Anna de Armas', salary: 2_000_000}
})
movie.cast = null
// garbage collector do clean it
// 03- methods
function viralDance() {
//Ichu Ichu Song
}
const dogesh = {
name:'husky',
dance: viralDance
}
// activities by methods
dogesh.dance = function (){
// Ichu Ichu song
}
const dogesh = {
name:'husky',
dance:function () {
//Ichu Ichu Song
}
}
// shorthand method prop
const dogesh = {
name:'husky',
dance() {
//Ichu Ichu Song
}
}
//
let user = {
name,
age,
college,
passedOut,
gf,
intro() {
// user.name
// user.age
// user.college
// user.gf
}
}
let piyush = user
user=null
piyush.intro()
// jessa sang use rang
// arrow is transparency glass
// this is just like chamelom
// contemplate
// 4 new operator
// It is mostly used in constructor function
// used to construct object
// capital Name // first letter Capital
// should be executed by new operator
function User (name) {
this.name = name ;
this.isPaid = false ;
}
const anirudh = new User('Ani') ; // User {}
// new does these things
this = {} ;
property assign
// return this
// optional chaining
const user = {
name, email,
address :{
full,
zip
}
}
// user.address.city
// agar address ho toh city me jana
// user.address ?.city
if(user.address){
if(user.address.city) {
// user.address.city
}
else {
// full address
}
else return ""
}
// logica or returnn// first truthy and last truthy
// && first falsy and last truthy value
// Symbol
// Object keys should be string and Symbol
// primitive unique value with description
let baby = Symbol("Ladla") ;
// Symbols are always unique even after its descriptions are same
// use case
// hidden property , for in loop skip by
// globalSymbol
// they exist in global symbol registry
let org = Symbol.for("Chaicode") ;
let company = Symbol.for("Chaicode") ;
Symbol.keyfor(org)
// System Symbol
Symbol.Iterator
Symbol.toPrimtive
// Date object add and subtract
[Symbol.toPrimitive](hint) {}
hint=> string,number,default
// default is concatenation
// toString
const galgota = {
status :"wasted",
aura:-1000,
[Symbol.toPrimitive](hint) {
if(hint === "string") return this.status
if(hint === "number") return this.aura
return this.aura
}
}
// number bigint string boolean null undefined Sybol
// null and undefined are pure primitive
// Boxing
// let str = ""
// Wrapper object create which gives access of methods
let million = 1_000_000 ;
million = 1e6 ;
// e is used to zero
let cr = 4e7 ;
// 4e1 40
// 4e9
// 1e5
// 0xff // 0x hex
// 0b111 // binary
// 0o13 //
//Math.floor(Math.random() * (max-min+1)) + max-min ;
// min + Math.random() * (max-min)
// Json no trailing comma
Summary
This is all about basic object foundation in JavaScript. This is foundation and learn nee thing about the use of e for adding zero and also number system like hex, octal, binary etc.




