The number of values between braces { } must not exceed the number of the elements. What if the No of elements less | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

The number of values between braces { } must not exceed the number of the elements. What if the No of elements less

21st Jun 2019, 12:09 AM
Faisal Alghamdi
Faisal Alghamdi - avatar
4 Answers
+ 2
Which language?
21st Jun 2019, 12:58 AM
Denise Roßberg
Denise Roßberg - avatar
0
In Java, using less elements than the array is declared to hold, will assign any un-assigned elements as their “default” value for example: int[] arr = new int[2]; arr[0] = 10; arr[0] will return 10 and by default, arr[1] will return 0 if not assigned
21st Jun 2019, 2:43 AM
Jake
Jake - avatar
0
If you are talking about JavaScript, objects have no limit on what they can hold. Example of creating new item: var object1 = {}; function func1(){ let x = “newItem”; let y = 5; object1[x] = y; }; func1(); Returns object1 as: object1 = { newItem: 5 }
21st Jun 2019, 3:02 AM
YoBoi
0
ThNks everyone you are so good
21st Jun 2019, 6:56 PM
Faisal Alghamdi
Faisal Alghamdi - avatar