Home > Web Front-end > JS Tutorial > We are simplifying (literals(arrays and objects)) in Js.

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

Barbara Streisand
Release: 2024-11-28 06:52:10
Original
584 people have browsed it

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",
}
Copy after login

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

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"];
Copy after login

thanks for reading!
???????????

The above is the detailed content of We are simplifying (literals(arrays and objects)) in Js.. For more information, please follow other related articles on the PHP Chinese website!

source:dev.to
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template