Giter VIP home page Giter VIP logo

javascript-udemy-review's Introduction

Javascript Basic Commands

  • console.log('Hello World!'); -> Log the message between single (or double) quotes in console
  • var variableName = value; -> Declaring a variable In Javascript you don't need to declare the type of a variable. In this case the type will be automatically defined as 'undefined'
  • //line comment
  • /*multi-line/block comment*/
  • alert() -> Creates a pop-up window with the message contained between the parenthesis
  • prompt() -> Asks for an input from the user that can be stored in a variable
  • typeof -> returns the type of the variable/data described on it

Primitive Javascript Data Types

number

Floating point numbers, for decimal and integers

string

Sequence of characters, used for text

boolean

Logical data type that can only be true or false

undefined

Data Type of a variable that does not have a value yet

null

Also means 'non-existent'

Type coercion

Is the process of converting value from one type to another (such as string to number, object to boolean, and so on).

Variable mutation

When you mutate a variable you are modifying the original value.

Boolean Logic (NOT, AND & OR)

&& -> AND || -> OR ! -> NOT

if and else statements

if (condition1) { // block of code to be executed if condition1 is true } else if (condition2) { // block of code to be executed if the condition1 is false and condition2 is true } else { // block of code to be executed if the condition1 is false and condition2 is false }

The Ternary Operator and Switch Statements

condition ? block of code to be executed if condition is true : block of code to be executed if the condition1 is false;

switch(expression) { case x: // code block break; case y: // code block break; default: // code block }

This is how it works:

The switch expression is evaluated once. The value of the expression is compared with the values of each case. If there is a match, the associated block of code is executed.

Truthy and Falsy values and equality operators

Falsy values: undefined, null, 0, '', NaN Truthy values: NOT falsy values

The Equality Operator

== -> This operator does the type coercion. === -> This is a strict operator and it needs to be compared with variables of the same type.

!= -> Different operator that does type coercion !== -> Diffenrent strict operator

Loops and Iteration

for (statement 1; statement 2; statement 3) { // code block to be executed }

Statement 1 is executed (one time) before the execution of the code block. Statement 2 defines the condition for executing the code block. Statement 3 is executed (every time) after the code block has been executed.

while (condition) { // code block to be executed }

do { // code block to be executed } while (condition);

Break and Continue

The break statement "jumps out" of a loop. The continue statement "jumps over" one iteration in the loop.

Functions

function myFunction(p1, p2) { return p1 * p2; // The function returns the product of p1 and p2 }

Objects

var person = { firstName: 'John', surName: 'Smith', birthYear: 1983 };

Methods

var person = { firstName: "John", lastName : "Doe", id : 5566, fullName : function() { return this.firstName + " " + this.lastName; } };

In a function definition, this refers to the "owner" of the function. In the example above, this is the person object that "owns" the fullName function. In other words, this.firstName means the firstName property of this object.

Acessing Object Methods objectName.methodName()

javascript-udemy-review's People

Contributors

leandroreiz avatar

Watchers

 avatar

javascript-udemy-review's Issues

Error when updating servings in a recipe

When trying to update the servings in a recipe the error below is displayed on Console and the values are not updated.

fractyError

Recently the library utilized to convert decimals to fraction where altered from "fractional" to "fracty" due to an error using Parcel.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.