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
Barbara StreisandOriginal
2024-11-28 06:52:10626browse

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",
}

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"];

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!

Statement:
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