Concise JavaScript Function Syntax

If the arrow function only takes a single argument, you don’t need parentheses. You can’t remove parentheses on functions with no or multiple arguments.

If you’re only using one line of code, you don’t need the return keyword.

You can reduce the syntax further by removing the curly braces when you only have a single line of code

JavaScript

JavaScript syntax is so familiar. It reminds me a lot of C++ but I assume most, if not all programming languages, look similar to that. I love how generalized variable declarations are in JavaScript as apposed to C++, though I also love the specifics of how you would declare them in C++.

One thing I don’t understand is how creating objects in JavaScript would be useful in web development. I understand how they would help in game development but not for websites. What do you think? I’m certainly no expert by any means in JavaScript or any language to be perfectly honest so I would love some input here. What are your thoughts on JavaScript, C++, HTML, or any web development or object oriented languages?

CSS 3D Experiment

Thinking of making a form out of this, it would be cool.

I post regular stories and daily updates on my Instagram.
Follow me on Instagram

Looping JavaScript Arrays

  So I have a small question: What’s wrong with my code? I’m trying to obviously just loop through and print the contents of this array and I’m new to JavaScript but nothing really looks wrong to me? I pasted the errors I’ve received below.

var locations = [
       "One",
       "Two",
       "Three"

];

function createArray() {

   for (var i = 0; i < locations.length(); i++)
   {
       alert(locations[i] + “\n”;);
   }
}



12: Expected ’]’ at column 5, not column 1.];


20: Missing ‘use strict’ statement.for (var i = 0; i < locations.length(); i++)


20: Move 'var’ declarations to the top of the function.for (var i = 0; i < locations.length(); i++)


20: Stopping. (83% scanned).for (var i = 0; i < locations.length(); i++)

Thanks for any assistance!

It Happened

Well, it happened. I created a Twitter account. The name is “@_CodeMaster_”. I’ll still be posting my main things here since the character count per post is much greater but I’ll be using Twitter for more personal posts about what’s going on throughout the day with code or anything really and will try to interact with you easier and in real time should you have any questions.

The link is in my bio.

More On Linux

  Linux users are all about customization. I know that Linux is, supposedly, vastly more secure and private than most other OS’s and that’s great but that being said, I don’t care whatsoever about customization. I DO care a great deal about my security and privacy. However, due to the fact that doing the simplest tasks is so difficult for no reason leads me to question why someone would take steps backwards in terms of ease of use. Why not have a GUI and still have customization and security? Maybe I’m missing something here. If so, please feel free to let me know. Thank you.

instagram

Emmet Comes Built-In with Visual Code

I post a lot more than this on my Instagram every day! Follow me there!