DEV Community

Natália Catunda
Natália Catunda

Posted on

We are simplifying (literals(arrays and objects)) in Js.

Objects

in Javascript, a literal object is the best way to simplify an object if you don't support idle talk, and if you prefer to go straight to the point.(without initializernew Object();)
you use{} and you have keywords as strings and the value can be data like numbers, strings, arrays, functions, etc...
Below is an example :

const fruit={
name: "apple",
weight:50,
color: "red",
}
Enter fullscreen mode Exit fullscreen mode

Arrays

You also use literal arrays on js, with [], simplifying too in the majority of cases, but you can remember that you just use normal Array when you want to use a specific empty element on your array
Below is an example of Literal Arrays :

const fruits = ["apple", "banana", "orange"];
Enter fullscreen mode Exit fullscreen mode

thanks for reading!
🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄🦄

SurveyJS custom survey software

Build Your Own Forms without Manual Coding

SurveyJS UI libraries let you build a JSON-based form management system that integrates with any backend, giving you full control over your data with no user limits. Includes support for custom question types, skip logic, an integrated CSS editor, PDF export, real-time analytics, and more.

Learn more

Top comments (1)

Collapse
 
mccauliflower_99 profile image
McCall Tucker
Comment hidden by post author

Some comments have been hidden by the post's author - find out more

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay