+ 8

Could you explain?

var a=1; document.write(a++); document.write(++a); Output is 13

17th Aug 2019, 7:29 AM
Safaa Alnabhan
Safaa Alnabhan - avatar
18 Respuestas
+ 6
a++ is post-increment, hence it print value of a (which is 1) and increment it. So now a has become 2. ++a is pre-increment so now the value of a(which is already 2) increases by 1, and a becomes 3 and then it will be printed. Since there is no next line, output you get is 13.
18th Aug 2019, 7:20 AM
Shaista Sid 🌸
Shaista Sid 🌸 - avatar
+ 13
document.write(a++) // Write a which is 1 and increment it. document.write(++a) // Increment a (now 3) and write it (3). There was no line break so both numbers are next to each other: 13.
17th Aug 2019, 7:37 AM
Paul Grasser
Paul Grasser - avatar
+ 9
ans : import * as
8th Apr 2020, 12:00 AM
Mizanur Rahman Pranto
+ 6
a++: first outputted, then incremented (to 2) ++a: first incremented (to 3), then outputted
17th Aug 2019, 9:52 AM
Paolo De Nictolis
Paolo De Nictolis - avatar
+ 4
there are prefix and postfix increments so by this write istead of writeline results are written near by each other.
17th Aug 2019, 12:02 PM
Moosa Kalanaki
Moosa Kalanaki - avatar
+ 4
This is not 13.This is 1 and 3 concat.
18th Aug 2019, 4:20 AM
Allumini
Allumini - avatar
+ 3
You forgot make a line break...
17th Aug 2019, 4:27 PM
YusufYaser
YusufYaser - avatar
+ 2
Fill in the blanks to import the following from "util/calc.js": export const hit = (x, y, z) => { return x * y + z / 2; } export const degree = 50; import * as calc from "util/calc"; calc.hit(1, 2, calc.degree);
4th May 2020, 2:26 PM
Eve Chibwe
Eve Chibwe - avatar
+ 2
ans = import * as
28th Jun 2020, 5:11 PM
Faith Mundi
Faith Mundi - avatar
+ 1
Your question has been thoroughly answered? @Safaa There are two outputs: The first document.write outputs 1, The second one outputs 3 Since there is no space, separator or line break, they are written side by side to appear as 13 when actually it should be 1 and 3.
18th Aug 2019, 11:54 PM
Philips Ekuma
Philips Ekuma - avatar
+ 1
Fill in the blanks to import the following from "util/calc.js": export const hit = (x, y, z) => { return x * y + z / 2; } export const degree = 50; * calc from "util/calc"; calc.hit(1, 2, calc.degree);
19th Aug 2019, 10:22 AM
HOPE ENOCK FUNKE
HOPE ENOCK FUNKE - avatar
+ 1
The ans is not 13
28th Jun 2020, 5:12 PM
Faith Mundi
Faith Mundi - avatar
+ 1
import * as calc from "util/calc"; calc.hit(1, 2, calc.degree);
3rd Dec 2020, 7:57 PM
El Maslohi Hassan
+ 1
Fill in the blanks to import the following from "util/calc.js": export const hit = (x, y, z) => { return x * y + z / 2; } export const degree = 50; import * as calc from "util/calc"; calc.hit(1, 2, calc.degree);
20th Jul 2021, 4:15 AM
Mohammad Dagher
Mohammad Dagher - avatar
+ 1
ANSWER : "import * as "
17th Sep 2021, 4:47 AM
Chandramouli
Chandramouli - avatar
0
Fill in the blanks to import the following from "util/calc.js": export const hit = (x, y, z) => { return x * y + z / 2; } export const degree = 50; import * calc from "util/calc"; calc.hit(1, 2, calc.degree);
28th Feb 2020, 1:49 PM
NK Designer
NK Designer - avatar
0
import as
30th Jul 2020, 8:58 AM
kedir.y
kedir.y - avatar
0
import as
17th Sep 2022, 9:44 AM
Frank Osei Afful