I
I
Ivan Ivanov2020-06-29 22:35:53
JavaScript
Ivan Ivanov, 2020-06-29 22:35:53

How else can you create value?

I mainly program in php. Started learning javascript. Can I somehow create variables through an array? (something like this (this is in php): $a = array("gey"=>89, "dery"=> "hello")?

Ps I saw how they write document.write(a["hey"])?
( hey this is the name if that)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Arman Hovhannisyan, 2020-06-30
@HegrihagRes

Associative Arrays in js since ecmascript 2015
var arr = new Map([
['key1', 'value1'],
['key2', 'value2'],
['key3', 'value3']
]);

A
Alexey Tsarapkin, 2020-06-29
@Dreamka

Obviously
php .

$fruits = ["Яблоко", "Апельсин", "Слива"];

print( $fruits[0] ); // Яблоко
print( $fruits[1] ); // Апельсин
print( $fruits[2] ); // Слива

js
let fruits = ["Яблоко", "Апельсин", "Слива"];

alert( fruits[0] ); // Яблоко
alert( fruits[1] ); // Апельсин
alert( fruits[2] ); // Слива

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question