DEV Community

Lincoln W Daniel
Lincoln W Daniel

Posted on

 

How to Use JavaScript Functions - Crash Course [Video]

Functions are another necessary part of programming in JavaScript. When building programs in JavaScript, you should use functions to organize your program into smaller, executable pieces of code that are responsible for specific actions. With your functions defined, you can call them from anywhere in your program with arguments that can influence the result.

In this video, we learn how to declare JavaScript functions with a name and arguments, call a function with parameters, and return a result. We also learn how to define functions on objects as methods and access the properties of the object within the function.

Along the way, we explore the DRY and Single Responsibility (SRP) principles for keeping our code clean and easy to reason about. By the end of this tutorial, you should have a strong understanding of how to use functions in JavaScript to build better programs.

My LinkedIn profile: https://www.LinkedIn.com/in/LincolnWDaniel
My website: http://www.LincolnWDaniel.com
1Liner Blog: https://www.1Liner.dev

Top comments (0)

11 Tips That Make You a Better Typescript Programmer

typescript

1 Think in {Set}

Type is an everyday concept to programmers, but it’s surprisingly difficult to define it succinctly. I find it helpful to use Set as a conceptual model instead.

#2 Understand declared type and narrowed type

One extremely powerful typescript feature is automatic type narrowing based on control flow. This means a variable has two types associated with it at any specific point of code location: a declaration type and a narrowed type.

#3 Use discriminated union instead of optional fields

...

Read the whole post now!