+ 1

Codes in one line?

I know this is inconvenient, but can we just write codes in only a few lines?

11th May 2017, 3:13 AM
Theerockzz
Theerockzz - avatar
3 Respuestas
+ 6
Yes, you can... and it could be useful for short code snippet, as you can execute commands ( even declare functions ) on a webpage conrext, trough the address bar of browsers ^^ Try to paste and go this as an url: javascript:alert(document.body.innerHTML); Obviously, as a valid url, you can even use it in the 'href' attribute of an <a> tag ;)
11th May 2017, 5:14 AM
visph
visph - avatar
+ 4
Yes we can. But it is a good habit to write in multiple lines. Thus making the code clearer to understand
11th May 2017, 3:21 AM
Reverse Leo😵
Reverse Leo😵 - avatar
+ 3
Yes, you can all code in one line. Below is a Javascript code with a multiplication function: var a = 856; var b = 235; function multiply(a, b) { return a * b; } var c = multiply(a, b); If you would write it in a single line, it would be: function multiply(a,b){return a*b}var a=856,b=235,c=multiply(a,b); Btw the single line code also called minify code, which is the common production file format in the web server. The program that we write for testing should not be in minify format, it only converts to minify version when the codes are tested and ready to be uploaded to web server. There are many tools online to do code minify, it's also called code uglify since the code is hard to read in single line.
11th May 2017, 3:36 AM
Calviղ
Calviղ - avatar