+ 1

How is it possible for document.write (1 + "<br/>") ; gives 1 and a line break and while document.write(1 + <br/>) doesn't.i don't understand the concept because it only understands the string..someone please help am confused

15th Jun 2016, 10:12 AM
Ozii
Ozii - avatar
4 odpowiedzi
+ 5
document.write(1+<br/>) is not possible because "+" is concatination and it use to add variable.
15th Jun 2016, 11:10 AM
Paulo Sevilla
Paulo Sevilla - avatar
+ 2
+ treated as concatenation operator and it works with strings, and strings enclosed in quotation marks..
21st Jun 2016, 8:41 AM
Sudhir Dilip Salunkhe
Sudhir Dilip Salunkhe - avatar
+ 2
i + <br/> is considered as two strings so o/p is I<br/> but "<br/>" the code is executed as HTML break tag.so o/p is I and break
24th Jun 2016, 10:43 AM
Karadi Sathyajith
Karadi Sathyajith - avatar
+ 2
Html and JavaScript are two different languages. it means that if you do this in HTML: <p> dothemath () </p> then HTML won't trigger the function. The catch here is, document.write is a function that writes to the HTML file. JavaScript can write stuff in the HTML even if it doesn't understand or make sense of. it can just write anything to the document as long as it's a string. after that, it's up to the HTML to make sense of it, or not.
23rd Jul 2016, 11:44 AM
Dr.Na'el Hariri
Dr.Na'el Hariri - avatar