Learning JavaScript: Fundamental Concepts

View this post on Instagram

LEARNING JAVASCRIPT FUNDAMENTALS CONCEPTS by @codeherk COMMENTS Single Line Comments: Begin with ‘//’. Multi Line Comments: Begin with ‘/*’ and end ‘*/’. NOTE: Adding ‘;’ at the end of statements is optional, but you MAY have issues later if you don’t! VARIABLES Variables are declared with ‘var’ or ‘let’. These variables can be changed. On the other hand, constants are declared with ‘const’ and they can be changed after being defined. NOTE: It’s recommended to use let instead of var. For more info, look up “JS Variable Scopes” CONDITIONALS Conditional statements check whether a specified condition is true or false. It determines what event happens next. It involves an if statement. Else if and else statements are optional. LOOPS Loops allow you to execute lines of code repeatedly until a specified condition is reached. Below is a for loop. There are multiple types of loops in Javascript: for, while, do-while, for-in, and for-of. QUESTION: numbers[2] = ? FUNCTIONS Rather than coding the same lines out multiple times in different situations, create a function and simply call it when needed. Adding comments will allow yourself and others to further understand the code. Some IDEs may even provide a preview (see above). When countOddEven() is called, it executes the instructions in the defined code block. THANK YOU Follow @codeherk for tips on Software Development. QUESTIONS FOR YOU Do you use var when declaring variables? Do you add comments, before, during, or after coding? . . . . #code #coder #coding #programmer #programmerslife #softwareengineer #engineeringstudent #computerscience #compsci #devlife #codelife #codeblog #science #peoplewhocode #technology #motivation #onlyup #codinglife #lovecoders #developer #worldofprogrammers #programming #programminglife #nodejs #javascriptdeveloper #javascript #learntocode

A post shared by Byron (@codeherk) on

COMMENTS

Single Line Comments: Begin with ‘//’.

Multi Line Comments: Begin with ‘/’ and end ‘/’.

NOTE: Adding ‘;’ at the end of statements is optional, but you MAY have issues later if you don’t! Learn more about it here

VARIABLES

Variables are declared with ‘var’ or ‘let’. These variables can be changed. On the other hand, constants are declared with ‘const’ and they can be changed after being defined.

NOTE: It’s recommended to use let instead of var. For more info, look up “JS Variable Scopes”

CONDITIONALS

Conditional statements check whether a specified condition is true or false. It determines what event happens next. It involves an if statement. Else if and else statements are optional.

LOOPS

Loops allow you to execute lines of code repeatedly until a specified condition is reached. Below is a for loop. There are multiple types of loops in Javascript: for, while, do-while, for-in, and for-of.

QUESTION: numbers[2] = ?

FUNCTIONS

Rather than coding the same lines out multiple times in different situations, create a function and simply call it when needed.

Adding comments will allow yourself and others to further understand the code. Some IDEs may even provide a preview (see above).

When countOddEven() is called, it executes the instructions in the defined code block.

THANK YOU

Follow @codeherk for tips on Software Development

QUESTIONS

Do you still use var in JavaScript? Do you add comments, before, during, or after coding?